ARTICLE AD BOX
I am developing a Flutter chat application that displays videos in a feed (similar to WhatsApp). Recently, after updating my Flutter SDK and changing my Android compileSdk to 36, video playback has completely broken or plays glitchy on a specific device.
It works perfectly fine on most of my testing devices (like iOS devices, Samsung devices, etc.). However, on one specific device (a Redmi phone), videos completely refuse to play or play with severe glitches. They often show a constant loading indicator or just a black screen, and the hardware decoder seems to fail.
The Setup:
Flutter SDK: Latest stable
Package: video_player: ^2.11.1 (using standard VideoPlayerController.networkUrl)
Android compileSdk: 36 (had to upgrade from 35 due to other plugin requirements)
Implementation: Storing instances of VideoPlayerController in a list and building
VideoPlayer widgets in a ListView/Column.
The Issue & Logs:
Previously, before the SDK and compileSdk updates, these exact same videos played perfectly fine on this exact same device.
Now, when initializing the VideoPlayerController, the video often fails to start rendering, and the logs get flooded with decoder and BufferQueueProducer loop errors.
Here are the relevant Logcat traces from the failing device:
textW/AudioCapabilities(26151): Unsupported mime audio/x-adpcm-ms
W/AudioCapabilities(26151): Unsupported mime audio/x-adp
...
/OMXClient(26151): IOmx service obtained
D/SurfaceUtils(26151): connecting to surface 0x785f6d4010, reason connectToSurface
D/Surface (26151): Surface::connect(this=0x785f6d4000,api=3)
I/BufferQueueProducer(26151): [ImageReader-1x1f22m7-26151-3](this:0x7801d2b800,id:3,api:3,p:26151,c:26151) connect(P): api=3 producer=(26151:com.my.app) producerControlledByApp=true
I/MediaCodec(26151): [OMX.MTK.VIDEO.DECODER.AVC] setting surface generation to 26778628
D/SurfaceUtils(26151): disconnecting from surface 0x785f6d4010, reason connectToSurface(reconnect)
D/Surface (26151): Surface::disconnect(this=0x785f6d4000,api=3)
I/BufferQueueProducer(26151): [ImageReader-1x1f22m7-26151-3](this:0x7801d2b800,id:3,api:3,p:26151,c:26151) disconnect(P): api 3
D/SurfaceUtils(26151): connecting to surface 0x785f6d4010, reason connectToSurface(reconnect)
D/Surface (26151): Surface::connect(this=0x785f6d4000,api=3)
It also occasionally throws: java.lang.IllegalArgumentException: start failed.
What I suspect:
Since the video_player_android plugin uses androidx.media3 (ExoPlayer) under the hood, I suspect that updating compileSdk to 36 forced Gradle to pull in a newer version of the Media3 ExoPlayer libraries. This newer version, combined with Flutter's Android embedding surface creation logic, seems to have intermittent hardware encoder buffer allocation failures on this specific device.
I tried degrading compileSdk back down to 35, but I am blocked because several other Flutter firestore/core plugins now explicitly require compileSdk 36.
Questions:
Is there a way to force the flutter video_player to use a specific, older version of androidx.media3 that might not have this surface reallocation loop?
Has anyone encountered this ExoPlayer hardware decoder glitch/issue on specific Android devices? Is there a client-side configuration or capability flag I can pass to VideoPlayerController to bypass this?
Could this be related to how Flutter 3.27 handles Texture rendering on Android?
Any guidance on how to fix this without ripping out the entire video player infrastructure would be amazing.
