Open ChernyshovYuriy opened 1 year ago
Thanks for reporting.
Releasing on the main thread is allowed. I don't agree with the author of the error message that says that calling a binder generally needs to be moved off the main thread. It's true that a two-way binder call like ISession.onDestroy()
can be blocked by a malicious remote application, but here it's the system that implements the endpoint.
It certainly shouldn't block that long that this triggers a ANR. ISession.destroySession()
is implemented here and basically calls through to here. In these two places the session is released. I'm not sure why this takes so long in the case that produces the stack trace above.
Do you see this often and on other devices than the above? As the stack trace above is from analytics, I guess you can't repro to create a bug report?
More out of curiosity: why is the service stopped when the app is in the background on a TV device?
Not many users affected, only 9, but that is because I applied radical solution - once onDestroy received and all shut down actions are completed:
android.os.Process.killProcess(android.os.Process.myPid())
I know this is anti pattern but good as temporary solution to understand the root cause. I have a timer in the app, i suspect it is triggering destroy while app is playing in background. I dont have much logs to support this but there is no other reason onDestroy invoked in background.
Version
Media3 1.1.1
More version details
This is reported for 1.2.0-beta01.
Devices that reproduce the issue
Android 11, Haier TV, Changhong TV. Application is in background.
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
The Firebase Crashlytics reports this ANR:
main (native):tid=1 systid=6234
00 pc 0x5ddec libc.so (syscall + 28)
01 pc 0x130dd9 libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*) + 88)
02 pc 0x4d8c33 libart.so (art::GoToRunnable(art::Thread*) + 342)
03 pc 0x4d8ab5 libart.so (art::JniMethodEnd(unsigned int, art::Thread*) + 8)
Expected result
I am not sure whether or not session should be release on main thread. Please correct the documentation if necessary.
Actual result
ANR when media session release.
Media
No specific media.
Bug Report
adb bugreport
to android-media-github@google.com after filing this issue.