bumptech / glide

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

Glide encountered an abnormal loading of a certain URL, while there are currently no issues with other URLs. #5454

Open marchlqq opened 1 week ago

marchlqq commented 1 week ago

Loading images through Glide, this way of loading, linking https://i-blog.csdnimg.cn/direct/efed520f694b4f31aa30e236c7bfa0ed.jpeg Cannot load normally.

Specific code: // Glide.with(this) // .load(url) // .into(imageView); or // Glide.with(this) // .asBitmap() // .load(url) // .apply(requestOptions) // .into(new ImageViewTarget(imageView) { // @Override // protected void setResource(@Nullable Bitmap resource) { // imageView.setImageBitmap(resource); // } // });

By querying the Android folder and glide cache, it can be confirmed that the image download is successful and can be previewed on the PC end. Moreover, images can also be loaded normally through BitmapFactory. decodeFile (filePath, options). Verified by the Picasso framework, it can be loaded normally. So, it can be concluded that the Glide framework encountered problems when parsing into a bitmap. Can you help to query and fix it?

marchlqq commented 1 week ago

Partial exception log: Load failed for [https://i-blog.csdnimg.cn/direct/efed520f694b4f31aa30e236c7bfa0ed.jpeg] with dimensions [1440x400] class com.bumptech.glide.load.engine.GlideException: Failed to load resource There were 24 root causes: java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.RuntimeException(setDataSourceCallback failed: status = 0x80000000) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.RuntimeException(setDataSourceCallback failed: status = 0x80000000) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.RuntimeException(setDataSourceCallback failed: status = 0x80000000) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.RuntimeException(setDataSource failed: status = 0x80000000) java.lang.RuntimeException(setDataSource failed: status = 0x80000000) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.RuntimeException(setDataSourceCallback failed: status = 0x80000000) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.RuntimeException(setDataSourceCallback failed: status = 0x80000000) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.RuntimeException(setDataSourceCallback failed: status = 0x80000000) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.RuntimeException(setDataSource failed: status = 0x80000000) java.lang.RuntimeException(setDataSource failed: status = 0x80000000) call GlideException#logRootCauses(String) for more detail Cause (1 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{DirectByteBuffer->Object->Drawable}, DATA_DISK_CACHE, https://i-blog.csdnimg.cn/direct/efed520f694b4f31aa30e236c7bfa0ed.jpeg There were 6 root causes: java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.RuntimeException(setDataSourceCallback failed: status = 0x80000000) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.RuntimeException(setDataSourceCallback failed: status = 0x80000000) java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.RuntimeException(setDataSourceCallback failed: status = 0x80000000) call GlideException#logRootCauses(String) for more detail Cause (1 of 4): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->Drawable->Drawable} There were 2 root causes: java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2)) java.lang.RuntimeException(setDataSourceCallback failed: status = 0x80000000) call GlideException#logRootCauses(String) for more detail Cause (1 of 2): class java.lang.IndexOutOfBoundsException: index=-2023161846 out of bounds (limit=86, nb=2) Cause (2 of 2): class java.lang.RuntimeException: setDataSourceCallback failed: status = 0x80000000 Cause (2 of 4): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->GifDrawable->Drawable} Cause (3 of 4): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->Bitmap->BitmapDrawable} There were 2 root causes: java.lang.IndexOutOfBoundsException(index=-2023161846 out of bounds (limit=86, nb=2))

marchlqq commented 1 week ago

Is there no one handling the issue with Glide now?

marchlqq commented 1 week ago

class:DefaultImageHeaderParser int tagCount = segmentData.getInt16(firstIfdOffset);

private static final class RandomAccessReader {

short getInt16(int offset) {
  return isAvailable(offset, 2) ? data.getShort(offset) : -1;
}

the code: data.getShort(offset) has exception:Method threw 'java.lang.IndexOutOfBoundsException' exception.

marchlqq commented 1 week ago

private int getOrientation(Reader reader, ArrayPool byteArrayPool) throws IOException { try { final int magicNumber = reader.getUInt16(); // .... } catch (Reader.EndOfFileException e) { // TODO(b/143917798): Re-enable this logging when dependent tests are fixed. // if (Log.isLoggable(TAG, Log.ERROR)) { // Log.e(TAG, "Unexpected EOF", e); // } return UNKNOWN_ORIENTATION; } }

modify Reader.EndOfFileException to Exception } catch (Exception e) {

can finish this issue

marchlqq commented 1 week ago

Can solve this problem. But packing aar is more troublesome. I have packed 3 aars here, namely libray, gif_decoder, and disklrucache.

marchlqq commented 1 week ago
implementation(name: 'glide-4.16.0-release', ext: 'aar')
implementation ("com.github.bumptech.glide:gifdecoder:4.16.0")
implementation ("com.github.bumptech.glide:disklrucache:4.16.0")
implementation ("com.github.bumptech.glide:annotations:4.16.0")
NGC185air110 commented 3 days ago

This is a recurring issue; I occasionally encounter certain phones that function properly while others do not. The status code is 0x80000000.