-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
This is related to #19206 and #19358.
VideoPlayer plugin on Android allocates a platform MediaPlayer object for each VideoPlayer plugin in the widget tree. MediaPlayer objects are destroyed when corresponding Flutter widgets go away. But if a whole FlutterView is destroyed, dispose methods don't run, so MediaPlayer instances are not released. This leads to leaks and also crashes (since the player continues to provide frames for non-existent surfaces; internal bug: b/112692333).
IMO, VideoPlayer should rely on normal disposing for the final cleanup and just assert that by the time the view is destroyed all resources are released. This would rely on widgets disposal methods to be called, which is tracked in #19358.
As a workaround, VideoPlayer should subscribe with a onViewDestroyListener and explicitly release all resources when the owner FlutterView goes away.