-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Deadlock with android_content_provider #1063
Comments
Hey @ryanheise, would you mind taking a look? If the solution really is as simple as removing the If you need any additional info, please let us know! |
Hi, I just wanted to note that we were able to work around the issue by implementing our content provider in Kotlin/Java instead of Flutter. However, I want to leave this issue open because eventually it may become essential to access data from our Flutter app in our content provider, and this issue prevents that. |
Documented on ryanheise#1063
Documented behaviour
Loading artwork through an Android ContentProvider with the android_content_provider package.
Actual behaviour
Sometimes playing a new media item with an
artUri
usingandroid_content_provider
can freeze the app. It seems like a race condition causing a deadlock.It hangs on this code:
audio_service/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioService.java
Lines 639 to 642 in ed856d6
What I believe is happening:
audio_service
callssetMediaItem
for item 1.AudioService
class in java because it's synchronized.audio_service
callssetMediaItem
for item 2.AudioService
.audio_service
receives a callback from the OS for building the notification (buildNotification
) for item 1.audio_service
as it has to wait for thesetMediaItem
call to complete.setMediaItem
never completes because theandroid_content_provider
hangs while waiting for a response from our content provider.audio_service
is blocking the flutter thread while waiting for a response fromsetMediaItem
, causing a deadlock whereandroid_content_provider
can't send back a response to the java method.Here's an export of the threads in the hanged state: threads_report.txt
Removing synchronized from the code above fixes the issue, but I'm not sure of the consequences of doing this.
Because of this, I think the issue lies within audio_service, but please let me know what you think so I can try and get this fixed!
Minimal reproduction project
https://github.com/puff/audio_service/tree/deadlock_content_provider
Reproduction steps
Output of flutter doctor
Devices exhibiting the bug
Pixel 8 - Android 14
The text was updated successfully, but these errors were encountered: