Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In 4.11.0 crash generating thumbnails of big sized videos #4165

Closed
sergiambel opened this issue Mar 30, 2020 · 15 comments
Closed

In 4.11.0 crash generating thumbnails of big sized videos #4165

sergiambel opened this issue Mar 30, 2020 · 15 comments
Labels

Comments

@sergiambel
Copy link

sergiambel commented Mar 30, 2020

Glide Version: 4.11.0

Integration libraries: Default installation

Device/Android Version: Huawei p30 Android 10

Issue details / Repro steps / Use case background:
Closes (crashes) the activity when try to load a big sized video file into an imageview. Running well with previous versions (4.10.0) Tested with 2Gb video file.

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

Glide.with(mActivity)
                    .load(video_data.getContentUri())
                    .apply(options)
                    .transition(DrawableTransitionOptions.withCrossFade())
                    .centerCrop()
                    .into(holder.image_view_picture);

Stack trace / LogCat:

2020-03-30 16:15:43.677 1248-1364/cast.to.big A/libc: FORTIFY: read: count 18446744071704558641 > SSIZE_MAX
2020-03-30 16:15:43.677 1248-1364/cast.to.big A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 1364 (glide-source-th), pid 1248 (cast.to.big)

It runs great if we use 4.10.0 Glide version instance of 4.11.0

@sjudd sjudd added the bug label Mar 30, 2020
@ghost
Copy link

ghost commented Mar 31, 2020

I had the same problem. Most on Huawei devices.

@tomasvalek
Copy link

I had the same problem in 4.11 version. Huawei Nova 3 Android Pie.
Version 4.10 is OK.

A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 22638 (glide-source-th), pid 22068 (main)

signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
2020-04-14 12:58:38.789 22663-22663/? A/DEBUG: Abort message: 'FORTIFY: read: count 18446744072810121891 > SSIZE_MAX'
backtrace:
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #00 pc 0000000000022988  /system/lib64/libc.so (abort+116)
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #01 pc 0000000000048160  /system/lib64/libc.so (__fortify_fatal(char const*, ...)+120)
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #02 pc 0000000000048630  /system/lib64/libc.so (__read_chk+68)
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #03 pc 0000000000002550  /system/lib64/libdrmbitmap.huawei.so (android::SkDrmFileStream::isDrmFile(int)+316)
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #04 pc 0000000000001e44  /system/lib64/libdrmbitmap.huawei.so (nativeDecodeFileDescriptorEx(_JNIEnv*, _jobject*, _jobject*, _jobject*, _jobject*)+304)
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #05 pc 000000000041de34  /system/framework/arm64/boot-framework.oat (offset 0x415000) (android.graphics.BitmapFactory.nativeDecodeFileDescriptor [DEDUPED]+228)
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #06 pc 000000000057204c  /system/lib64/libart.so (art_quick_invoke_static_stub+604)
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #07 pc 00000000000d4d4c  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+232)
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #08 pc 000000000028810c  /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #09 pc 0000000000282114  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968)
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #10 pc 0000000000542d04  /system/lib64/libart.so (MterpInvokeStatic+204)
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #11 pc 0000000000564514  /system/lib64/libart.so (ExecuteMterpImpl+14612)
2020-04-14 12:58:38.940 22663-22663/? A/DEBUG:     #12 pc 00000000004806f6  /system/framework/boot-framework.vdex (android.graphics.BitmapFactory.decodeFileDescriptor+40)

@Truvuong123
Copy link

This crash also occured when load too large bitmap (more than 8192x8192) only in glide v4.

@perracodex
Copy link

Could you let me know what has changed about the video frames retrieval in glide 4.11 in relation with 4.10?

I've done the test to build manually a list of video thumbnails by directly using the MediaMetadataRetriever.getFrameAtTime() API.
When using this framework API it works with no issues, but with the same test videos glide crashes.

@perracodex
Copy link

I've also tried MediaMetadataRetriever.getScaledFrameAtTime, with several parameter combinations and I can't make it crash.
So probably is not a problem with the MediaMetadataRetriever, but something that happens in Glide before or after the video thumbnail has been extracted from the file.

@perracodex
Copy link

perracodex commented Jun 26, 2020

I could pinpoint where the crash happens, yet I cannot understand yet the reason why it happens. Next a few screenshots.
It happens in the the ImageReader class, when trying to decode a bitmap via the Downsampler using a file descriptor.

image

image

image

image

@perracodex
Copy link

Can this be related to issue #4116 ?
Must take into account that although this seems to be a Huawei bug, Glide 4.10 doesn't present such issue.

@sjudd
Copy link
Collaborator

sjudd commented Jun 26, 2020

Can you attach a file that reproduces the issue? I don't have a device right now, but I might be able to get one in the future.

If you are able to reproduce it, can you do so by just calling BitmapFactory.decodeFileDescriptor directly without using Glide? If so, does it also reproduce if you call BitmapFactory.decodeStream on the same file? If it's only an issue with decodeFileDescriptor, we could probably avoid registering the file descriptor decoder on affected Huawei devices, assuming we can get the SDK, manufacturer name, and maybe device model if it's only some of their devices with a given SDK.

@perracodex
Copy link

perracodex commented Jun 26, 2020

Finally I can reproduce the crash without Glide.

I've done a few test by directly calling BitmapFactory.decodeFileDescriptor over a few video Uris.

The result is that for normal (smaller) videos it doesn't retrieve anything at all. It returns null bitmaps, or -1 metrics when using inJustDecodeBounds=true .

Yet, when performing the test with the big video file, I get the same crash as in glide.

Now the questions is, why does glide use BitmapFactory.decodeFileDescriptor for video files? Is this valid?
I mean, I couldn't get any bitmap from any video with this method. So, shouldn't be always use the MediaMetadataRetriever API, or I'm mistaken?

Just a quick thought, doesn't the Downsampler should be getting only the file descriptors for cached bitmaps? Could it be that is getting also the file descriptor of the actual target video file?

Edit: I've checked the size of the file targeted in Downsampler->ImageReader.decodeBitmap(), by evaluating dataRewinder.rewindAndGet().getStatSize() before decoding gets executed.
The size matches the one of the video file, meaning that effectively is the video file itself and not a cached bitmap.
Not sure if this is right or wrong, but I would had thought that at this point as the call comes from the Downsampler, the file descriptor should be from a cached bitmap and not the video file.

Same crash as glide:

2020-06-26 22:03:00.815 15601-15601/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2020-06-26 22:03:00.816 15601-15601/? A/DEBUG: Build fingerprint: 'HUAWEI/SNE-LX1/HWSNE:9/HUAWEISNE-L21/291C432:user/release-keys'
2020-06-26 22:03:00.816 15601-15601/? A/DEBUG: Revision: '0'
2020-06-26 22:03:00.816 15601-15601/? A/DEBUG: ABI: 'arm64'
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG: Happend: 'Fri Jun 26 22:03:00 2020
    '
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG: SYSVMTYPE: Art
    APPVMTYPE: Art
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG: pid: 15449, tid: 15449, name: om.example.test  >>> com.example.test <<<
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG: Abort message: 'FORTIFY: read: count 18446744071594576062 > SSIZE_MAX'
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG:     x0  0000000000000000  x1  0000000000003c59  x2  0000000000000006  x3  0000000000000008
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG:     x4  0000000000808080  x5  0000000000808080  x6  0000000000808080  x7  0000000000000030
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG:     x8  0000000000000083  x9  2ce8fe5450398ffe  x10 0000000000000000  x11 fffffffc7ffffbdf
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG:     x12 0000000000000001  x13 000000005ef65474  x14 000a3cb13d151000  x15 00000a32452aa3fc
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG:     x16 0000007aa86312c0  x17 0000007aa856fe34  x18 0000000000000001  x19 0000000000003c59
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG:     x20 0000000000003c59  x21 ffffffff81f008be  x22 0000007aab00a5e0  x23 0000007fd9a2ae78
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG:     x24 0000007fd9a2ae74  x25 0000000000000000  x26 0000007a24815ca0  x27 0000000000000003
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG:     x28 0000007aab00a5e0  x29 0000007fd9a29690
2020-06-26 22:03:00.817 15601-15601/? A/DEBUG:     sp  0000007fd9a29650  lr  0000007aa8564960  pc  0000007aa8564988
2020-06-26 22:03:00.905 15601-15601/? A/DEBUG: backtrace:
2020-06-26 22:03:00.905 15601-15601/? A/DEBUG:     #00 pc 0000000000022988  /system/lib64/libc.so (abort+116)
2020-06-26 22:03:00.905 15601-15601/? A/DEBUG:     #01 pc 0000000000048160  /system/lib64/libc.so (__fortify_fatal(char const*, ...)+120)
2020-06-26 22:03:00.905 15601-15601/? A/DEBUG:     #02 pc 0000000000048630  /system/lib64/libc.so (__read_chk+68)
2020-06-26 22:03:00.905 15601-15601/? A/DEBUG:     #03 pc 0000000000002550  /system/lib64/libdrmbitmap.huawei.so (android::SkDrmFileStream::isDrmFile(int)+316)
2020-06-26 22:03:00.905 15601-15601/? A/DEBUG:     #04 pc 0000000000001e44  /system/lib64/libdrmbitmap.huawei.so (nativeDecodeFileDescriptorEx(_JNIEnv*, _jobject*, _jobject*, _jobject*, _jobject*)+304)
2020-06-26 22:03:00.905 15601-15601/? A/DEBUG:     #05 pc 000000000041de34  /system/framework/arm64/boot-framework.oat (offset 0x415000) (android.graphics.BitmapFactory.nativeDecodeFileDescriptor [DEDUPED]+228)
2020-06-26 22:03:00.905 15601-15601/? A/DEBUG:     #06 pc 000000000057830c  /system/lib64/libart.so
2020-06-26 22:03:01.263 1433-15604/? W/ActivityManager:   finishTopCrashedActivityLocked Force finishing activity com.example.test/.MainActivity
2020-06-26 22:03:01.264 852-852/? E//system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_00

@perracodex
Copy link

The issue still happens in 4.12.0.

The source of the bug is that Glide is incorrectly trying to decode a video thumbnail using the BitmapFactory, so passing a video file descriptor to BitmapFactory.decodeFileDescriptor. This is incorrect as the BitmapFactory is meant for image files only, not for videos.

The reason it fails in some devices is just unpredictable, since is passing a file descriptor of a specific file type to a class which doesn't expect such file type.

@sergiambel
Copy link
Author

no fixed in 4.12.0 :(

@gondeveloper
Copy link

The crash continues in 4.12.0! Please fix it...

@Roberto7588
Copy link

Roberto7588 commented Jan 30, 2021

Still crashing in 4.12.0.
I can't upgrade and I'm stuck at 4.10.0, because the problem started in 4.11.0.

@AdaDai
Copy link

AdaDai commented Sep 10, 2021

We have the same problem, please fix it as soon as possible...

@sjudd
Copy link
Collaborator

sjudd commented Oct 4, 2021

Sorry I'm just circling back to this, so I think I'm going to start with trying the getStatSize fix suggested here: #4165 (comment). Arbitrarily I'll experiment with some maximum file sizes around 512mb, but please let me know if you have input. These will go out internally at first as experiments so I can try to verify the size is reasonable.

I don't see this issue on any manufacturer other than Huawei, please let me know if you do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants