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

Main application hangs when call mediaplayer stop #91

Closed
kuoliangkwong opened this issue Feb 1, 2018 · 8 comments
Closed

Main application hangs when call mediaplayer stop #91

kuoliangkwong opened this issue Feb 1, 2018 · 8 comments

Comments

@kuoliangkwong
Copy link

kuoliangkwong commented Feb 1, 2018

This only happens to my Samsung S4, Android v5.0.1. Other devices work fine.

Here's the log it says:
02-01 15:24:19.294 7259-7265/com.videoeditor.kruso.dev I/art: Thread[2,tid=7265,WaitingInMainSignalCatcherLoop,Thread*=0xaf90e400,peer=0x12c8b080,"Signal Catcher"]: reacting to signal 3 02-01 15:24:20.999 7259-7265/com.videoeditor.kruso.dev I/art: Wrote stack traces to '/data/anr/traces.txt'

I also pulled the traces.txt from my device:
traces.txt

After the hang and then force close the app, other video apps no longer able to open any video, till I restart my device.

I did abit of debug and notice the app hangs at net.protyposis.android.mediaplayer.Decoders.java release() method.

p/s: I'm using the master branch after the #81 fix

@protyposis
Copy link
Owner

Do you get the same behavior with v4.3.2 before fix #81? Is it reliably reproducible? Does it always happen or only occasionally?

At first sight it looks like the lock in MediaPlayer.stop() that was fixed in #81 is stuck, but I guess it only waits for the PlaybackThread to finish, which itself seems to be stuck in MediaCodec.stop(). I've seen the video codec also crash system wide on other old Samsung devices which had to be rebooted to get it working again. This was because the decoders were not stopped correctly and after a few instances all resources were used up.

@kuoliangkwong
Copy link
Author

kuoliangkwong commented Feb 2, 2018

Do you get the same behavior with v4.3.2 before fix #81?

Yes, tried 4.3.2, and still the same.

Is it reliably reproducible?

Yes~ very often it happens

Does it always happen or only occasionally?

It happens occasionally, sometimes it works, but it fails very often

Will that happen if we reinit the decoders when it has not been released? We have a code where we open and close the video multiple times.

@kuoliangkwong
Copy link
Author

kuoliangkwong commented Feb 2, 2018

In addition, i noticed if i seek frame within the last second of a video, then play the video, the video will just stuck for few mins, then continue play to the end. This also happened in MediaPlayer-Extended app in Google Play in most of my devices. Is it the same issue too? It happens occasionally.

@protyposis
Copy link
Owner

Yes it can happen when too many decoders are created and old ones are not fully destroyed. I'm afraid I won't be able to analyze or fix this issue without an actual affected device. I'll take a look if I have an S4 somewhere to test but I doubt that.

The second issue seems unrelated. Please test if it also happens when you set the seek mode to SeekMode.FAST_TO_CLOSEST_SYNC and if so, open a separate issue.

@kuoliangkwong
Copy link
Author

sure~ I'll check again on my code and see if it has incorrect flow.

For second issue, it seems ok when set to SeekMode.FAST_TO_CLOSEST_SYNC. Is there any way we can fix if we wanna use SeekMode.EXACT?

@kuoliangkwong
Copy link
Author

For first issue, I checked my code and noticed it will hang when it calls prepare video before setSurface. I updated my code to prepare video after setSurface, then everything is working again.

@protyposis
Copy link
Owner

Great, so this issue is solved? Yes setSurface must always be called before prepare, but actually there should be an exception if the surface isn't set.

Regarding seeking, please open a separate issue and post the logcat output from a seek. It might be related to the GOP size of your video.

@kuoliangkwong
Copy link
Author

kuoliangkwong commented Feb 6, 2018

Yea I guess it's considered solved.

Yup ok. I'll create another for second issue. Thanks alot for your help.

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

No branches or pull requests

2 participants