Issue 1:
Glide Version: 4.12.0

Integration libraries: okhttp3-4.9.0

Device/Android Version: OPPO A5/Android8.1.0

Issue details / Repro steps / Use case background:

Glide load line / GlideModule (if any) / list Adapter code (if any):

Glide.with...

Layout XML:

<FrameLayout xmlns:android="...

Stack trace / LogCat:

# main(2)

java.lang.NullPointerException

Attempt to read from field 'com.bumptech.glide.load.engine.DecodeJob$DiskCacheProvider com.bumptech.glide.load.engine.Engine$DecodeJobFactory.diskCacheProvider' on a null object reference

1
com.bumptech.glide.load.engine.Engine$DecodeJobFactory$1.create(Engine.java:483)
2
com.bumptech.glide.load.engine.Engine$DecodeJobFactory$1.create(Engine.java:480)
3
com.bumptech.glide.util.pool.FactoryPools$FactoryPool.acquire(FactoryPools.java:163)
4
com.bumptech.glide.load.engine.Engine$DecodeJobFactory.build(Engine.java:511)
5
com.bumptech.glide.load.engine.Engine.waitForExistingOrStartNewJob(Engine.java:266)
6
com.bumptech.glide.load.engine.Engine.load(Engine.java:193)
7
com.bumptech.glide.request.SingleRequest.onSizeReady(SingleRequest.java:451)
8
com.bumptech.glide.request.target.ViewTarget$SizeDeterminer.notifyCbs(ViewTarget.java:352)
9
com.bumptech.glide.request.target.ViewTarget$SizeDeterminer.checkCurrentDimens(ViewTarget.java:368)
10
com.bumptech.glide.request.target.ViewTarget$SizeDeterminer$SizeDeterminerLayoutListener.onPreDraw(ViewTarget.java:513)
11
android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:977)
12
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2772)
13
android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1718)
14
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7513)
15
android.view.Choreographer$CallbackRecord.run(Choreographer.java:1066)
16
android.view.Choreographer.doCallbacks(Choreographer.java:878)
17
android.view.Choreographer.doFrame(Choreographer.java:794)
18
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1052)
19
android.os.Handler.handleCallback(Handler.java:790)
20
android.os.Handler.dispatchMessage(Handler.java:99)
21
android.os.Looper.loop(Looper.java:210)
22
android.app.ActivityThread.main(ActivityThread.java:7080)
23
java.lang.reflect.Method.invoke(Native Method)
24
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:523)
25
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:863)

Issue 2:
I would like to find a way to cache the webview images myself, as some of them may be used in the future in an imageview. Currently, I can find out when an image will be loaded and get its url through the webview's shouldInterceptRequest.

I've tried using Glide's submit call, but the loading is significantly slower. I've also noticed that calling it this way still makes the request check on the ui thread if the webview is valid before proceeding, which may add notable overhead to so many requests. Is there any way to improve this?

My web response:

class FrostImageResponse(view: WebView, url: String) : WebResourceResponse("", "", null) {

val futureBitmap = GlideApp.with(view).asBitmap().load(url).submit()

override fun getData(): InputStream {
val bos = ByteArrayOutputStream()
futureBitmap.get().compress(CompressFormat.PNG, 0 /*ignored for PNG*/, bos)
val bitmapdata = bos.toByteArray()
return ByteArrayInputStream(bitmapdata)
}
}