Skip to content

[Android] ImageReaderSurfaceProducer still fails on Huawei Kirin API31 devices despite fix for #166481 #188560

Open

Description

@dong11

This appears to be closely related to the Huawei ImageReader workaround introduced for #166481. The current workaround excludes Huawei devices running API29 and below, but we can reproduce a nearly identical failure signature on a Huawei Kirin9000 device running Android 12 (API31).

Steps to reproduce

  1. Create a Flutter application using video_player.

  2. Play an H.264 MP4 video using the default Texture rendering mode (VideoViewType.textureView).

  3. Run on a Huawei Kirin device:

    • Device: NOH-AN01
    • Chipset: Kirin 9000
    • Android 12 (API 31)
  4. Initialize VideoPlayerController.

Expected results

The video should initialize and play normally.

Actual results

Video initialization fails with:

PlatformException(VideoError)

androidx.media3.exoplayer.ExoPlaybackException

MediaCodecRenderer$DecoderInitializationException

Decoder init failed:
OMX.hisi.video.decoder.avc

Relevant logcat:

format_supported=YES

ImageReader-1x...

native_window_set_buffer_count failed

IGraphicBufferProducer::setBufferCount

Failed to allocate buffers

Codec reported err 0xffffffea

Code sample

final videoPlayerController = VideoPlayerController.networkUrl(
Uri.parse(videoUrl),
);
videoPlayerController.initialize();

Screenshots or Video

No response

Logs

Logs
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer: Failed to initialize decoder: OMX.hisi.video.decoder.avc
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:   java.lang.IllegalStateException
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at android.media.MediaCodec.native_stop(Native Method)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at android.media.MediaCodec.stop(MediaCodec.java:2300)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter.release(SourceFile:40)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter$Factory.createAdapter(SourceFile:16)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.mediacodec.DefaultMediaCodecAdapterFactory.createAdapter(SourceFile:84)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.initCodec(SourceFile:78)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(SourceFile:111)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(SourceFile:83)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onInputFormatChanged(SourceFile:76)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onInputFormatChanged(SourceFile:1)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(SourceFile:22)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(SourceFile:35)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(SourceFile:19)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.RendererHolder.render(SourceFile:11)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(SourceFile:116)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(SourceFile:370)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at android.os.Handler.dispatchMessage(Handler.java:113)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at android.os.Looper.loopOnce(Looper.java:205)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at android.os.Looper.loop(Looper.java:293)
06-25 13:01:50.049 17884 18460 W MediaCodecRenderer:       at android.os.HandlerThread.run(HandlerThread.java:110)
06-25 13:01:50.049  2704  2940 I DeviceStateService: app: cn.shuwenkeji.kouyudashi pid: 17884 start mediacodec.
06-25 13:01:50.050  2704  2940 I DeviceStateService: event is too short, not process app: cn.shuwenkeji.kouyudashi mediacodec action.
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer: Video codec error
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:   androidx.media3.exoplayer.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.hisi.video.decoder.avc, Format(1, null, video/mp4, video/avc, avc1.4D401F, 366136, und, [1920, 1080, 29.989916, ColorInfo(BT709, Limited range, SDR SMPTE 170M, false, 8bit Luma, 8bit Chroma)], [-1, -1])
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(SourceFile:143)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(SourceFile:83)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onInputFormatChanged(SourceFile:76)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onInputFormatChanged(SourceFile:1)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(SourceFile:22)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(SourceFile:35)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(SourceFile:19)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.RendererHolder.render(SourceFile:11)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(SourceFile:116)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(SourceFile:370)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at android.os.Handler.dispatchMessage(Handler.java:113)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at android.os.Looper.loopOnce(Looper.java:205)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at android.os.Looper.loop(Looper.java:293)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at android.os.HandlerThread.run(HandlerThread.java:110)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:   Caused by: java.lang.IllegalStateException
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at android.media.MediaCodec.native_stop(Native Method)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at android.media.MediaCodec.stop(MediaCodec.java:2300)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter.release(SourceFile:40)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter$Factory.createAdapter(SourceFile:16)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.mediacodec.DefaultMediaCodecAdapterFactory.createAdapter(SourceFile:84)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.initCodec(SourceFile:78)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(SourceFile:111)
06-25 13:01:50.050 17884 18460 E MediaCodecVideoRenderer:       ... 13 more
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal: Playback error
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:   androidx.media3.exoplayer.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, video/mp4, video/avc, avc1.4D401F, 366136, und, [1920, 1080, 29.989916, ColorInfo(BT709, Limited range, SDR SMPTE 170M, false, 8bit Luma, 8bit Chroma)], [-1, -1]), format_supported=YES
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.BaseRenderer.createRendererException(SourceFile:10)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.BaseRenderer.createRendererException(SourceFile:1)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(SourceFile:103)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onInputFormatChanged(SourceFile:76)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onInputFormatChanged(SourceFile:1)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(SourceFile:22)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(SourceFile:35)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(SourceFile:19)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.RendererHolder.render(SourceFile:11)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(SourceFile:116)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(SourceFile:370)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at android.os.Handler.dispatchMessage(Handler.java:113)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at android.os.Looper.loopOnce(Looper.java:205)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at android.os.Looper.loop(Looper.java:293)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at android.os.HandlerThread.run(HandlerThread.java:110)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:   Caused by: androidx.media3.exoplayer.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.hisi.video.decoder.avc, Format(1, null, video/mp4, video/avc, avc1.4D401F, 366136, und, [1920, 1080, 29.989916, ColorInfo(BT709, Limited range, SDR SMPTE 170M, false, 8bit Luma, 8bit Chroma)], [-1, -1])
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(SourceFile:143)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(SourceFile:83)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       ... 12 more
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:   Caused by: java.lang.IllegalStateException
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at android.media.MediaCodec.native_stop(Native Method)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at android.media.MediaCodec.stop(MediaCodec.java:2300)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter.release(SourceFile:40)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter$Factory.createAdapter(SourceFile:16)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.DefaultMediaCodecAdapterFactory.createAdapter(SourceFile:84)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.initCodec(SourceFile:78)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(SourceFile:111)
06-25 13:01:50.051 17884 18460 E ExoPlayerImplInternal:       ... 13 more
06-25 13:01:50.051  1370 18445 I VDEC    : VIDEO:[vadpt_exit]:[948] vadpt_exit info, sec_flag:0, ref_cnt:1, sec_ref_cnt:0
06-25 13:01:50.051  1370 18445 I Decoder : VIDEO:[~Decoder]:[85] deinit

Flutter Doctor output

Doctor output
 Flutter version 3.44.2
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c9a6c48423 
    • Engine revision 77e2e94772
    • Dart version 3.12.2
    • DevTools version 2.57.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, no-enable-swift-package-manager,
      omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration

[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [6.8s]
    • Emulator version 34.1.20.0 (build_id 11610631) (CL:N/A)
    • Platform android-36, build-tools 36.1.0
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
    • All Android licenses accepted.

Activity

  1. dong11 commented on Jun 25, 2026

    @dong11
    Author

    Investigation

    The following have been verified.

    Video file

    Verified with multiple encodings:

    • H.264 Baseline
    • H.264 Main
    • H.264 High
    • Level 3.1
    • Level 4.0
    • 720P
    • 1080P
    • yuv420p
    • AAC

    The same file plays correctly elsewhere.


    Media3

    The official AndroidX Media3 demo application plays the same MP4 successfully.

    Therefore the issue does not appear to be Media3 or ExoPlayer.


    Browser

    Huawei Browser plays the same MP4 successfully.


    video_player_android

    Tested with:

    • latest version
    • 2.8.4

    Both reproduce the same failure.

    Therefore this is not related to the recent video_player_android changes.


    PlatformView

    Using

    VideoViewType.platformView
    

    works correctly.


    Texture

    Using

    VideoViewType.textureView
    

    fails.

    The log shows that Flutter is using:

    ImageReaderSurfaceProducer
    

    Important finding

    Flutter already contains the Huawei workaround introduced by fix-huawei-imagereader-166481.

    Current implementation:

    private static boolean hasAndroidHardwareBufferDefect() {
      return Build.VERSION.SDK_INT <= API_LEVELS.API_29
          && "HUAWEI".equalsIgnoreCase(Build.MANUFACTURER);
    }

    Since this device is running API31, Flutter still selects:

    ImageReaderSurfaceProducer
    

    instead of

    SurfaceTextureSurfaceProducer
    

    Verification

    Setting

    FlutterRenderer.debugForceSurfaceProducerGlTextures = true;

    before FlutterEngine initialization makes the same application work correctly on the same device.

    Results:

    Rendering path Result
    AndroidX Media3 + SurfaceView ✅ Works
    Flutter PlatformView ✅ Works
    Flutter Texture + ImageReaderSurfaceProducer ❌ Fails
    Flutter Texture + SurfaceTextureSurfaceProducer (debugForceSurfaceProducerGlTextures=true) ✅ Works

    No other code changes were made.


    Conclusion

    This strongly suggests that the issue is not related to:

    • MP4 file
    • H.264 encoding
    • Media3
    • ExoPlayer
    • video_player_android

    The issue appears to be specific to Flutter Engine's ImageReaderSurfaceProducer on Huawei Kirin devices running Android 12 (API31).

    The workaround added for #166481 appears to solve the same class of issue on API29 devices, but does not currently cover this API31 Huawei device.


    Additional information

    The failure signature is very similar to the one documented in the existing Huawei workaround:

    OMX.hisi.video.decoder.avc
    
    Failed to allocate buffers
    
    native_window_set_buffer_count failed
    

    The only difference is that the device is running Android 12 (API31), so the current workaround is not applied.

    If needed, I can provide:

    • a minimal reproduction project
    • complete logcat
    • device information
    • sample MP4
  2. added
    in triagePresently being triaged by the triage team
    c: crashStack traces logged to the console
    platform-androidAndroid applications specifically
    engineflutter/engine related. See also e: labels.
    packageflutter/packages repository. See also p: labels.
    team-androidOwned by Android platform team
    fyi-ecosystemFor the attention of Ecosystem team
    and removed
    in triagePresently being triaged by the triage team
    on Jun 25, 2026
  3. self-assigned this
    on Jun 30, 2026
  4. gmackall commented on Jun 30, 2026

    @gmackall
    Member

    I'll try to get my hands on an api ~35 huawei device to see if this is broken still on the newer-est versions of android+huawei

  5. serbandin commented on Jul 7, 2026

    @serbandin
    Contributor

    Hi, I would do the following test in order to know if that flag would help for API31 as well (I don't have one at hand unfortunately):
    Then try setting FlutterRenderer.debugForceSurfaceProducerGlTextures = true in an example app. If the video plays then that is a strong signal that this method should be updated to include the tested device.

  6. gmackall commented on Jul 15, 2026

    @gmackall
    Member

    I'll try to get my hands on an api ~35 huawei device to see if this is broken still on the newer-est versions of android+huawei

    Okay I had forgotten they are banned in the us, unassigning as I'm not going to be able to repro

  7. removed their assignment
    on Jul 15, 2026
  8. added
    triaged-androidTriaged by Android platform team
    P2Important issues not at the top of the work list
    on Jul 21, 2026
  9. YaKun-SH commented on Aug 4, 2026

    @YaKun-SH

    Using VideoViewType.textureView and adding FlutterRenderer. debugForceSurfaceProducerGalTextures=true can indeed solve the problem of video playback issues on Huawei Android 12 (API31). There is a ghosting issue when using VideoViewType.clatformView. Can this problem be solved?

    class MainActivity: FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
    FlutterRenderer.debugForceSurfaceProducerGlTextures = true
    super.onCreate(savedInstanceState)
    }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: crashStack traces logged to the consoleengineflutter/engine related. See also e: labels.p: video_playerThe Video Player pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions