bumptech / glide

An image loading and caching library for Android focused on smooth scrolling
https://bumptech.github.io/glide/
Other
34.57k stars 6.12k forks source link

In a weak network (3G), the local picture is displayed only after the network picture fails to load. #2998

Open yxcSini opened 6 years ago

yxcSini commented 6 years ago

Glide Version:4.3.0

Integration libraries:okhttp3

Device/Android Version:Android Emulator P 27

Issue details / Repro steps / Use case background: In a weak network (3G), the local picture is displayed only after the network picture fails to load.

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

Glide.with(this).load("http://img5.imgtn.bdimg.com/it/u=4054007864,2464688467&fm=27&gp=0.jpg").into(addImageView("Network Image"));
Glide.with(this).load("http://img.zcool.cn/community/01f17956138a5832f875a132eb1d85.jpg@1280w_1l_2o_100sh.jpg").into(addImageView("Network Image"));
Glide.with(this).load("http://img.zcool.cn/community/01ad9a56f29a3832f875a9448d2d7c.jpg").into(addImageView("Network Image"));
Glide.with(this).load("http://pic.58pic.com/58pic/13/76/61/33N58PICRdp_1024.jpg").into(addImageView("Network Image"));
Glide.with(this).load("http://img3.redocn.com/tupian/20150204/qingxinsuyashuyebiankuangppt_3868316.jpg").into(addImageView("Network Image"));
Glide.with(this).load("http://pic31.nipic.com/20130804/12906030_061954811000_2.png").into(addImageView("Network Image"));
new Handler().postDelayed(new Runnable() {
       @Override
       public void run() {
            Glide.with(TestBitmapActivity.this).load("/mnt/sdcard/temp.jpg").into(addImageView("local Image"));
      }
},2000);

Layout XML:

no xml

Stack trace / LogCat:

03-30 05:19:05.127 5057-5057/com.paisheng.example.pslib I/ViewTarget: Glide treats LayoutParams.WRAP_CONTENT as a request for an image the size of this device's screen dimensions. If you want to load the original image and are ok with the corresponding memory cost and OOMs (depending on the input size), use .override(Target.SIZE_ORIGINAL). Otherwise, use LayoutParams.MATCH_PARENT, set layout_width and layout_height to fixed dimension, or use .override() with fixed dimensions.
03-30 05:19:05.129 5057-5057/com.paisheng.example.pslib I/ViewTarget: Glide treats LayoutParams.WRAP_CONTENT as a request for an image the size of this device's screen dimensions. If you want to load the original image and are ok with the corresponding memory cost and OOMs (depending on the input size), use .override(Target.SIZE_ORIGINAL). Otherwise, use LayoutParams.MATCH_PARENT, set layout_width and layout_height to fixed dimension, or use .override() with fixed dimensions.
03-30 05:19:06.780 5057-5057/com.paisheng.example.pslib I/ViewTarget: Glide treats LayoutParams.WRAP_CONTENT as a request for an image the size of this device's screen dimensions. If you want to load the original image and are ok with the corresponding memory cost and OOMs (depending on the input size), use .override(Target.SIZE_ORIGINAL). Otherwise, use LayoutParams.MATCH_PARENT, set layout_width and layout_height to fixed dimension, or use .override() with fixed dimensions.
03-30 05:19:06.780 5057-5057/com.paisheng.example.pslib I/ViewTarget: Glide treats LayoutParams.WRAP_CONTENT as a request for an image the size of this device's screen dimensions. If you want to load the original image and are ok with the corresponding memory cost and OOMs (depending on the input size), use .override(Target.SIZE_ORIGINAL). Otherwise, use LayoutParams.MATCH_PARENT, set layout_width and layout_height to fixed dimension, or use .override() with fixed dimensions.
03-30 05:19:15.202 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for http://pic.58pic.com/58pic/13/76/61/33N58PICRdp_1024.jpg with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
03-30 05:19:19.633 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for http://img3.redocn.com/tupian/20150204/qingxinsuyashuyebiankuangppt_3868316.jpg with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
03-30 05:19:29.641 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for http://pic31.nipic.com/20130804/12906030_061954811000_2.png with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
03-30 05:19:31.668 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for http://img5.imgtn.bdimg.com/it/u=4054007864,2464688467&fm=27&gp=0.jpg with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
03-30 05:19:41.684 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for http://img.zcool.cn/community/01ad9a56f29a3832f875a9448d2d7c.jpg with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
03-30 05:19:47.693 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for http://img.zcool.cn/community/01f17956138a5832f875a132eb1d85.jpg@1280w_1l_2o_100sh.jpg with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
yxcSini commented 6 years ago

The local picture displays error logs only after the network picture fails to load.

03-30 05:24:22.384 5057-5057/com.paisheng.example.pslib I/ViewTarget: Glide treats LayoutParams.WRAP_CONTENT as a request for an image the size of this device's screen dimensions. If you want to load the original image and are ok with the corresponding memory cost and OOMs (depending on the input size), use .override(Target.SIZE_ORIGINAL). Otherwise, use LayoutParams.MATCH_PARENT, set layout_width and layout_height to fixed dimension, or use .override() with fixed dimensions.
03-30 05:24:22.385 5057-5057/com.paisheng.example.pslib I/ViewTarget: Glide treats LayoutParams.WRAP_CONTENT as a request for an image the size of this device's screen dimensions. If you want to load the original image and are ok with the corresponding memory cost and OOMs (depending on the input size), use .override(Target.SIZE_ORIGINAL). Otherwise, use LayoutParams.MATCH_PARENT, set layout_width and layout_height to fixed dimension, or use .override() with fixed dimensions.
03-30 05:24:24.108 5057-5057/com.paisheng.example.pslib I/ViewTarget: Glide treats LayoutParams.WRAP_CONTENT as a request for an image the size of this device's screen dimensions. If you want to load the original image and are ok with the corresponding memory cost and OOMs (depending on the input size), use .override(Target.SIZE_ORIGINAL). Otherwise, use LayoutParams.MATCH_PARENT, set layout_width and layout_height to fixed dimension, or use .override() with fixed dimensions.
03-30 05:24:24.108 5057-5057/com.paisheng.example.pslib I/ViewTarget: Glide treats LayoutParams.WRAP_CONTENT as a request for an image the size of this device's screen dimensions. If you want to load the original image and are ok with the corresponding memory cost and OOMs (depending on the input size), use .override(Target.SIZE_ORIGINAL). Otherwise, use LayoutParams.MATCH_PARENT, set layout_width and layout_height to fixed dimension, or use .override() with fixed dimensions.
03-30 05:24:32.430 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for http://img5.imgtn.bdimg.com/it/u=4054007864,2464688467&fm=27&gp=0.jpg with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
03-30 05:24:36.692 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for http://img3.redocn.com/tupian/20150204/qingxinsuyashuyebiankuangppt_3868316.jpg with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
03-30 05:24:42.744 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for http://pic31.nipic.com/20130804/12906030_061954811000_2.png with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
03-30 05:24:48.747 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for http://pic.58pic.com/58pic/13/76/61/33N58PICRdp_1024.jpg with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
03-30 05:24:52.795 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for http://img.zcool.cn/community/01ad9a56f29a3832f875a9448d2d7c.jpg with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
03-30 05:24:52.796 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for /mnt/sdcard/temp.jpg with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
                                                                   Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, LOCAL
                                                                     Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
                                                                       Cause (1 of 1): class java.io.FileNotFoundException: /mnt/sdcard/temp.jpg (No such file or directory)
                                                                   Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class android.os.ParcelFileDescriptor, LOCAL
                                                                     Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
                                                                       Cause (1 of 1): class java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
03-30 05:24:52.796 5057-5057/com.paisheng.example.pslib I/Glide: Root cause (1 of 2)
                                                                 java.io.FileNotFoundException: /mnt/sdcard/temp.jpg (No such file or directory)
                                                                     at java.io.FileInputStream.open0(Native Method)
                                                                     at java.io.FileInputStream.open(FileInputStream.java:231)
                                                                     at java.io.FileInputStream.<init>(FileInputStream.java:165)
                                                                     at java.io.FileInputStream.<init>(FileInputStream.java:112)
                                                                     at android.content.ContentResolver.openInputStream(ContentResolver.java:984)
                                                                     at com.bumptech.glide.load.data.StreamLocalUriFetcher.loadResourceFromUri(StreamLocalUriFetcher.java:87)
                                                                     at com.bumptech.glide.load.data.StreamLocalUriFetcher.loadResource(StreamLocalUriFetcher.java:62)
                                                                     at com.bumptech.glide.load.data.StreamLocalUriFetcher.loadResource(StreamLocalUriFetcher.java:17)
                                                                     at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:41)
                                                                     at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:96)
                                                                     at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
                                                                     at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:298)
                                                                     at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:268)
                                                                     at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:229)
                                                                     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                                                                     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                                                                     at java.lang.Thread.run(Thread.java:764)
                                                                     at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:413)
03-30 05:24:52.797 5057-5057/com.paisheng.example.pslib I/Glide: Root cause (2 of 2)
                                                                 java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
                                                                     at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:313)
                                                                     at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:211)
                                                                     at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1261)
                                                                     at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1189)
                                                                     at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:22)
                                                                     at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:14)
                                                                     at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:41)
                                                                     at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:96)
                                                                     at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
                                                                     at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:298)
                                                                     at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherFailed(DecodeJob.java:393)
                                                                     at com.bumptech.glide.load.engine.SourceGenerator.onLoadFailed(SourceGenerator.java:118)
                                                                     at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:149)
                                                                     at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:141)
                                                                     at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:46)
                                                                     at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:96)
                                                                     at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
                                                                     at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:298)
                                                                     at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:268)
                                                                     at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:229)
                                                                     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                                                                     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                                                                     at java.lang.Thread.run(Thread.java:764)
                                                                     at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:413)
03-30 05:24:58.782 5057-5057/com.paisheng.example.pslib W/Glide: Load failed for http://img.zcool.cn/community/01f17956138a5832f875a132eb1d85.jpg@1280w_1l_2o_100sh.jpg with size [2392x2392]
                                                                 class com.bumptech.glide.load.engine.GlideException: Failed to load resource
sjudd commented 6 years ago

Glide's default networking library uses Glide's resize service to run network RPCs. You can avoid this by picking a more robust networking library like OkHttp and using the integration library: http://bumptech.github.io/glide/int/okhttp3.html.

yxcSini commented 6 years ago

@sjudd It is not a problem that the network picture fails to load, but the local image cannot be displayed immediately when the network image is being loaded. The local image will not be displayed until the network image is loaded or fails.

yxcSini commented 6 years ago

@sjudd I already use okhttp3

sjudd commented 6 years ago

I'm aware that it's not a load error. The issue you're describing is that downloading slow remote images is blocking local images. Usually that happens because you're using the default networking library which doesn't use an independent thread to run network requests on.

If you're using OkHttp, are you using the integration library I pointed to? Or just in the rest of your app?

yxcSini commented 6 years ago

@sjudd
That is my config. //glide compile 'com.github.bumptech.glide:glide:4.3.0' compile "com.github.bumptech.glide:okhttp3-integration:4.3.0" annotationProcessor 'com.github.bumptech.glide:compiler:4.3.0'

sjudd commented 6 years ago

Are you able to reproduce it on 4.6.1? Can you attach a sample app or failing test case that reproduces the issue? http://bumptech.github.io/glide/tut/failing-test-cases.html

yxcSini commented 6 years ago

@sjudd This seems to be related to the type of network. Selecting UMTS in the emulator's network type, the network picture will block the loading of local pictures, the printed log will not see okhttp3. When selecting GSM it will not block and see okhttp3 log.

yxcSini commented 6 years ago

@sjudd GSM's log

03-31 02:18:20.984 21935-21935/com.example.glidetest W/Glide: Load failed for http://pic31.nipic.com/20130804/12906030_061954811000_2.png with size [2392x2392]
                                                              class com.bumptech.glide.load.engine.GlideException: Failed to load resource
                                                              There were 2 causes:
                                                              java.net.SocketTimeoutException(failed to connect to pic31.nipic.com/112.91.129.184 (port 80) from /10.0.2.15 (port 42476) after 10000ms)
                                                              java.io.FileNotFoundException(No content provider: http://pic31.nipic.com/20130804/12906030_061954811000_2.png)
                                                               call GlideException#logRootCauses(String) for more detail
                                                                Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE
                                                              There was 1 cause:
                                                              java.net.SocketTimeoutException(failed to connect to pic31.nipic.com/112.91.129.184 (port 80) from /10.0.2.15 (port 42476) after 10000ms)
                                                               call GlideException#logRootCauses(String) for more detail
                                                                  Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
                                                              There was 1 cause:
                                                              java.net.SocketTimeoutException(failed to connect to pic31.nipic.com/112.91.129.184 (port 80) from /10.0.2.15 (port 42476) after 10000ms)
                                                               call GlideException#logRootCauses(String) for more detail
                                                                    Cause (1 of 1): class java.net.SocketTimeoutException: failed to connect to pic31.nipic.com/112.91.129.184 (port 80) from /10.0.2.15 (port 42476) after 10000ms
                                                                Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class android.content.res.AssetFileDescriptor, LOCAL
                                                              There was 1 cause:
                                                              java.io.FileNotFoundException(No content provider: http://pic31.nipic.com/20130804/12906030_061954811000_2.png)
                                                               call GlideException#logRootCauses(String) for more detail
                                                                  Cause (1 of 1): class java.io.FileNotFoundException: No content provider: http://pic31.nipic.com/20130804/12906030_061954811000_2.png
03-31 02:18:20.984 21935-21935/com.example.glidetest I/Glide: Root cause (1 of 2)
                                                              java.net.SocketTimeoutException: failed to connect to pic31.nipic.com/112.91.129.184 (port 80) from /10.0.2.15 (port 42476) after 10000ms
                                                                  at libcore.io.IoBridge.connectErrno(IoBridge.java:185)
                                                                  at libcore.io.IoBridge.connect(IoBridge.java:129)
                                                                  at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:137)
                                                                  at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
                                                                  at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
                                                                  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
                                                                  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
                                                                  at java.net.Socket.connect(Socket.java:621)
                                                                  at okhttp3.internal.platform.AndroidPlatform.connectSocket(AndroidPlatform.java:70)
                                                                  at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:238)
                                                                  at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:158)
                                                                  at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:256)
                                                                  at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:134)
                                                                  at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:113)
                                                                  at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
                                                                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                                                                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
                                                                  at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
                                                                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                                                                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
                                                                  at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
                                                                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                                                                  at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
                                                                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                                                                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
                                                                  at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
                                                                  at okhttp3.RealCall$AsyncCall.execute(RealCall.java:147)
                                                                  at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
                                                                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                                                                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                                                                  at java.lang.Thread.run(Thread.java:764)
03-31 02:18:20.985 21935-21935/com.example.glidetest I/Glide: Root cause (2 of 2)
                                                              java.io.FileNotFoundException: No content provider: http://pic31.nipic.com/20130804/12906030_061954811000_2.png
                                                                  at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1415)
                                                                  at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1266)
                                                                  at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1189)
                                                                  at com.bumptech.glide.load.data.AssetFileDescriptorLocalUriFetcher.loadResource(AssetFileDescriptorLocalUriFetcher.java:22)
                                                                  at com.bumptech.glide.load.data.AssetFileDescriptorLocalUriFetcher.loadResource(AssetFileDescriptorLocalUriFetcher.java:13)
                                                                  at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:44)
                                                                  at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:62)
                                                                  at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:299)
                                                                  at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:269)
                                                                  at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:230)
                                                                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                                                                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                                                                  at java.lang.Thread.run(Thread.java:764)
                                                                  at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)

UMTS's log

03-31 02:21:25.877 21935-21935/com.example.glidetest W/Glide: Load failed for http://pic31.nipic.com/20130804/12906030_061954811000_2.png with size [2392x2392]
                                                              class com.bumptech.glide.load.engine.GlideException: Failed to load resource
                                                              There was 1 cause:
                                                              java.io.FileNotFoundException(No content provider: http://pic31.nipic.com/20130804/12906030_061954811000_2.png)
                                                               call GlideException#logRootCauses(String) for more detail
                                                                Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class android.content.res.AssetFileDescriptor, LOCAL, DataCacheKey{sourceKey=http://pic31.nipic.com/20130804/12906030_061954811000_2.png, signature=EmptySignature}
                                                              There was 1 cause:
                                                              java.io.FileNotFoundException(No content provider: http://pic31.nipic.com/20130804/12906030_061954811000_2.png)
                                                               call GlideException#logRootCauses(String) for more detail
                                                                  Cause (1 of 1): class java.io.FileNotFoundException: No content provider: http://pic31.nipic.com/20130804/12906030_061954811000_2.png
03-31 02:21:25.878 21935-21935/com.example.glidetest I/Glide: Root cause (1 of 1)
                                                              java.io.FileNotFoundException: No content provider: http://pic31.nipic.com/20130804/12906030_061954811000_2.png
                                                                  at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1415)
                                                                  at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1266)
                                                                  at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1189)
                                                                  at com.bumptech.glide.load.data.AssetFileDescriptorLocalUriFetcher.loadResource(AssetFileDescriptorLocalUriFetcher.java:22)
                                                                  at com.bumptech.glide.load.data.AssetFileDescriptorLocalUriFetcher.loadResource(AssetFileDescriptorLocalUriFetcher.java:13)
                                                                  at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:44)
                                                                  at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:62)
                                                                  at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:299)
                                                                  at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:269)
                                                                  at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:230)
                                                                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                                                                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                                                                  at java.lang.Thread.run(Thread.java:764)
                                                                  at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)
stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.

sjudd commented 6 years ago

Ah the no content provider thing is interesting in this context.

proft commented 6 years ago

The same error log No content provider if I select Network type = HSDPA in emulator settings. Image has not loaded.

Sdghasemi commented 5 years ago

I'm also using OkHttp and encountered this issue. I managed to reproduce it in my own case (Samsung Galaxy S8): Samsung devices come with a power saving feature which blocks the internet access for background apps which are added in an always sleeping list. I tried to load lots and lots of images as they're in the list on a rather slow connection and when the app was communicating with server and the network monitor graph was up, I pushed the app in the background and waited a few seconds then got back to the app and no server communication. Not only the images in the list was not getting loaded but I tried to load some new images and nothing came up. I even scrolled the list up to retry the requests which were going on before the network block and the same thing hit me. And not only one image loads until I changed the network and somehow android.permission.ACCESS_NETWORK_STATE gave me a hand to reset all I was trying to get and all Items loaded. So bottom line is a slow network with a lots of loading requests and a network block should do the reproduction process, I hope.

Sdghasemi commented 5 years ago

Any updates on this??

rasheedsulayman commented 5 years ago

I'm experiencing the same issue. No updates yet....

yihuaqi commented 5 years ago

@r4sh33d @Sdghasemi @yxcSini That's because the default OkHttpStreamFetcher returns a SocketInputStream which could block the source thread. Read all the bytes into memory and wrap it with ByteArrayInputStream could solve this issue. However there's a pitfall, setPriority will no longer work, because the GlideExecutor will consume the queue very fast.

            override fun onDataReady(stream: InputStream?) {
                if (stream != null) {
                    var inputStream = stream.readBytes().let { byteArray ->
                        size = byteArray.size.toLong()
                        ByteArrayInputStream(byteArray)
                    }
                }
                 super.onDataReady(inputStream)
            }
dingpengqiang commented 4 years ago

huawei mate7, android version 5.1.1 ,but Other test mobile phones are normal. glide log:

java.net.SocketTimeoutException: failed to connect to cp2.oss-cn-hangzhou.aliyuncs.com/47.110.23.53 (port 443) after 2500ms at libcore.io.IoBridge.connectErrno(IoBridge.java:181) at libcore.io.IoBridge.connect(IoBridge.java:122) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:456) at java.net.Socket.connect(Socket.java:935) at com.android.okhttp.internal.Platform.connectSocket(Platform.java:174) at com.android.okhttp.Connection.connect(Connection.java:152) at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:276) at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211) at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:382) at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106) at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89) at com.android.okhttp.internal.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:25) at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:104) at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:59) at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100) at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:164) at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:154) at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:65) at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100) at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:62) at com.bumptech.glide.load.engin