Repository navigation
fix(android): move native player deletion off the UI isolate - #413
Open
LinXunFeng wants to merge 3 commits into
Open
LinXunFeng wants to merge 3 commits into
LinXunFeng wants to merge 3 commits into
Conversation
Keep texture and callback teardown on the owning isolate, then await native deletion on a worker. Share disposal completion to prevent duplicate deletion and let the platform await resource release. Add a native slow-destruction fixture to verify UI responsiveness and disposal completion. The production codec ANR has not been reproduced on test devices.
Preserve retry after texture release errors while sharing native deletion completion.
Contributor
|
Verdict: this PR works for me. I'm shipping it (together with #418) in an IPTV app on Android TV. TV data for this PR
Tested this PR (Android 16 emulator)
Also found: a separate platform-view crash ( |
This was referenced Nov 15, 2026
misobadev
added a commit
to misobadev/neostation-frontend
that referenced
this pull request
Nov 23, 2026
…861) * fix(video): stop freezing the app when a preview player is released On some Android devices the hardware decoder never returns from MediaCodec::stop. fvp deleted the native player on the UI isolate, which Flutter runs on Android's main thread, so the app froze until Android killed it with an ANR (wang-bin/fvp#412). A user's log from an AYANEO Pocket FIT shows exactly that stack while browsing a list with video previews. Vendor fvp 0.40.0 into packages/fvp with the fix from wang-bin/fvp#413: native deletion runs in Isolate.run, so a stuck decoder leaks that one player instead of freezing the app. Hardware decoding stays on. Also pin the MDK SDK on Android to the v0.40.1 release and its SHA-256. fvp downloaded whatever nightly was current at build time, so 0.16.1 and 1.0.0-rc.2 shipped different libmdk.so builds from the same fvp version. * style(fvp): format the patched player.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #412.
Problem and change
Native player destruction can block while waiting for codec shutdown. Running
mdkPlayerAPI_deleteon the UI isolate can therefore freeze the Android main thread and trigger the ANR reported in #412.Move native deletion to a worker with
Isolate.run, after texture and callback teardown on the owning isolate. Concurrent disposal calls share completion so the native player is deleted only once. Preserve upstream awaitable disposal and allow retry after a texture release error.Production verification
We deployed this branch's fix in our newer app releases and have no longer observed this ANR there. The supplied Firebase Crashlytics screenshot shows the following counts for this specific issue in the displayed reporting scope:
These are app versions, not fvp versions. The screenshot supports the absence of reported events in that scope; it does not establish that the underlying vendor codec stall itself has been eliminated.
Local validation
flutter test --no-pub test/player_dispose_test.dart— passed on macOS. A native fixture delays destruction by 300 ms; the test checks UI-isolate responsiveness, exactly-once deletion, awaited completion, and retry after texture release failure.flutter analyze --no-pub lib/src/player.dart lib/src/video_player_mdk.dart test/player_dispose_test.dart— no issues found.git diff --check— passed.The fixture models slow native destruction; it does not reproduce the affected Android vendor codec hang. The branch has been merged with current upstream
masterto resolve disposal-related conflicts.