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

[media-library] RuntimeException "setDataSource failed" in MediaLibraryUtils.java #9839

Closed
ahmetbicer opened this issue Aug 19, 2020 · 5 comments · Fixed by #9855
Closed

Comments

@ahmetbicer
Copy link

ahmetbicer commented Aug 19, 2020

🐛 Bug Report

Summary of Issue

I am seeing some crash reports from users regarding to expo-media-library. When setDataSource called from MediaLibraryUtils.java, it throws a RuntimeException.

Environment - output of expo diagnostics & the platform(s) you're targeting

Bare react native project
"react-native": "0.63.2"
"expo-av": "^8.6.0",
"expo-media-library": "^9.2.0",
"react-native-unimodules": "^0.10.1",

buildToolsVersion = "29.0.0"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29

Stack Trace

I have two different stack traces but i think it is related to each other.

Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
       at android.os.AsyncTask$3.done(AsyncTask.java:354)
       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
       at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
       at java.util.concurrent.FutureTask.run(FutureTask.java:271)
       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)

Caused by java.lang.RuntimeException: setDataSource failed: status = 0x80000000
       at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java)
       at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:150)
       at expo.modules.medialibrary.MediaLibraryUtils.a(MediaLibraryUtils.java:47)
       at expo.modules.medialibrary.MediaLibraryUtils.a(MediaLibraryUtils.java:112)
       at expo.modules.medialibrary.GetAssets.doInBackground(GetAssets.java:70)
       at expo.modules.medialibrary.GetAssets.doInBackground(GetAssets.java:2)
       at android.os.AsyncTask$2.call(AsyncTask.java:333)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       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)
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
       at android.os.AsyncTask$3.done(AsyncTask.java:318)
       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
       at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
       at java.util.concurrent.FutureTask.run(FutureTask.java:242)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:760)

Caused by java.lang.RuntimeException: setDataSource failed: status = 0x80000000
       at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java)
       at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:136)
       at expo.modules.medialibrary.MediaLibraryUtils.convertMediaType(MediaLibraryUtils.java)
       at expo.modules.medialibrary.MediaLibraryUtils.convertMediaType(MediaLibraryUtils.java)
       at expo.modules.medialibrary.GetAssets.doInBackground(GetAssets.java)
       at expo.modules.medialibrary.GetAssets.doInBackground(GetAssets.java)
       at android.os.AsyncTask$2.call(AsyncTask.java:304)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:760)

There are some stack overflow questions with same error. You can see from this links. 1 2.

One of them says

It seems that setDataSource("path") returns a RuntimeException when something is wrong with the file.

and the other one says

Remove file:// from video URI before passing it to setDataSource method.

So maybe we just need to handle this exception to solve this. Sorry, i don't have a reproducible demo since i am not experiencing this. I will update it if i can reproduce the issue.

Thanks!

@ahmetbicer
Copy link
Author

ahmetbicer commented Aug 20, 2020

Hi @lukmccall,
Thanks for quick fix but i didn't quite understand what is going to happen when MediaMetaDataRetriever fails on some video. Is it just gonna skip that asset and doesn't show that in assets array?

@lukmccall
Copy link
Contributor

It will try to get move size and orientation from the Android database. I don't know if it returns the correct value - they can be flipped see. But I don't think we can do anything better in this case.

@ahmetbicer
Copy link
Author

Ok, so it will return that video in assets array but size and orientation may not be right. It is not a problem for me since i am not using that props in my app. Thanks again!

@barthap
Copy link
Contributor

barthap commented Aug 26, 2020

I did more investigation about this crash, because it's not the first time I see this happening - last time I caught it in image-picker (see this diff). It seems to be system-dependent (or media file/app dependant).
Just curious - on which Android devices the crash occurs? I crashed image-picker on LG Nexus 5 running Android 6.0 and recording with Camcorder app. However, when I used different recording app, it didn't crash.

@ahmetbicer
Copy link
Author

Hi @barthap i am listing all devices that crashed. Since #9855 i am not seeing any crashes in crashlytics.

Huawei P40 Lite Android 10
Huawei P20 PRO Android 10
OPPO RX17 Neo Android 9
Motorola Moto Z3 Play Android 9
Motorola Moto G7 Play Android 9
Samsung Galaxy S9+ Android 9
Sony Xperia XZ Android 8

lukmccall added a commit that referenced this issue Aug 31, 2020
…taRetriever` failed (#9855)

# Why

Probably fixes #9839 - I can't reproduce it. Hovewer, with `setDataSource failed: status = 0x80000000` we can't do anything. 

# How

Prevent from crashing when `MediaMetadaRetriver` throws a `RuntimeException`.

# Test Plan

- expo-client ✅

# Changelog

- Fixed `RuntimeException: setDataSource failed: status = 0x80000000` caused by `MediaMetadataRetriever`.
nahn20 pushed a commit to nahn20/expo-media-library that referenced this issue Mar 4, 2024
…taRetriever` failed (#9855)

# Why

Probably fixes expo/expo#9839 - I can't reproduce it. Hovewer, with `setDataSource failed: status = 0x80000000` we can't do anything. 

# How

Prevent from crashing when `MediaMetadaRetriver` throws a `RuntimeException`.

# Test Plan

- expo-client ✅

# Changelog

- Fixed `RuntimeException: setDataSource failed: status = 0x80000000` caused by `MediaMetadataRetriever`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants