bumptech / bumptech/glide

How to force Glide to use only the VideoDecoder

Open
#4,542 9 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
35k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
8

Description

**Glide Version**: 4.11, 4.12

**Device/Android Version**: Different Huawei models

**Issue details / Repro steps / Use case background**:

Is there a way to force a Glide request to use only the **VideoDecoder** to obtain thumbnails, when a file's media type is known to be a video?

My question is because I need to find a temporary workaround to avoid the crashes reported in issues #4165 and #4519, until these get fixed.
To put in context, and avoid repeating everything that is already explained in the above tickets, the bug is an uncatchable system crash which happens in different Huawei models when trying to get thumbnails from large video files (over 2GB).

Debugging Glide I've found that in its flow it also calls the **BitmapFactory.decodeFileDescriptor** for video files via the **Downsampler** class, to be more exact, the crash happens when trying to obtain the video thumbnail dimensions.

To avoid the crash, I guess that forcing to use the VideoDecoder when the type is known, would mitigate temporarily the issue.

See next screenshot for the frames stacktrace.
Is from when reading a video file.
As you can see marked in red, to get the video dimensions Glide is calling the **ImageReader.decodeBitmap** method, which content maps to a single **BitmapFactory.decodeFileDescriptor** call.
Glide shouldn't be calling such API to get video dimensions, as it is mean to be for image files only. So, even if doesn't crash in several devices, the behavior is unpredictable as is passing the file descriptor of an unsupported format.

![image](https://user-images.githubusercontent.com/7354233/113313042-29320780-930b-11eb-852a-01ca83818b55.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.