Skip to content

[Android] Video color-corrupted on TCL/PowerVR with every fvp decoder, but media_kit (also libmpv) renders fine on the same device #374

Open

Description

@abdelaziz-mahdy

On a TCL Google TV (Realtek RTD2875P SoC, PowerVR GPU, Android 12),
fvp plays streams (audio fine, decoding runs at full frame rate) but the
video picture is heavily color-corrupted — chromatic noise + block artifacts
across the whole frame — and stutters.

The decisive finding: media_kit (also libmpv-based) renders the exact same
streams perfectly on the exact same device.
Since both fvp/MDK and media_kit
use libmpv to demux/decode, the difference is the renderer — which points at
MDK's GL renderer / texture path on this PowerVR driver, not the GPU, libmpv,
or decoding.

Screenshot of the corruption:

Image

Decisive comparison

Engine (Flutter) Demux/decode Renders correctly on this device?
fvp 0.36.x (MDK GL renderer) libmpv ❌ corrupted
media_kit 1.2.6 (mpv vo_gpu) libmpv ✅ perfect (correct colors, smooth)

Same decoding stack, same streams, same GPU — only the renderer differs. fvp/MDK
corrupts; mpv's vo_gpu does not.

Environment

fvp 0.36.1 (MDK 0.36.0 (git d3ec2cc))
Flutter 3.44.2 (stable), engine 77e2e94772, Dart 3.12.2
video_player 2.11.1
ABI in use armeabi-v7a (32-bit) — MDK banner: Build for: Android21/31(12.0) ... 4KB ARMv7

Device

prop value
model TCL Smart TV G10_4K_US_NF (device G10)
board / platform rtd6748
SoC Realtek RTD2875P
GPU PowerVR (ro.hardware.vulkan = powervr)
OS Android 12 (API 31)
display 3840×2160 @ 60
EGL 1.5 Android META-EGL

Observations

  • Audio is correct.
  • Decoding is healthy: MediaCodec logs show steady queue/release at the
    content's native rate (~24–25 fps): [QIB]V, QIB:24/s / [ROB]V, ROB:25/s.
  • Video is color-garbled (looks like a YUV plane / stride / color-format
    misinterpretation) and stutters despite the decoder running at rate.
  • Non-video Flutter UI renders perfectly on the same GPU (Skia) — only the
    fvp video texture is wrong.

What I tried (every config shows the same corruption)

registerWith config Result
default (AMediaCodec, image=1) corrupted
video.decoders: ['AMediaCodec:image=0'] (SurfaceTexture/OES) corrupted
video.decoders: ['AMediaCodec:copy=1'] corrupted
video.decoders: ['FFmpeg'] (software) corrupted ← rules out the decoder
tunnel: true renders nothing (black) + crash on player dispose

Reproduces under both Flutter Skia (EnableImpeller=false) and Impeller
(Vulkan)
.

Questions

  1. Given media_kit's mpv vo_gpu renders correctly on this PowerVR driver, is
    there an MDK renderer / global option (color format, texture format, GL
    workaround) that would fix MDK's output here?
  2. Is there a supported way to render fvp to a native Android SurfaceView
    (system compositor) for video_player-based integrations?

Logs

MDK init banner:

MDK: 0.36.0 (git d3ec2cc) - Multimedia Development Kit.
MDK: Build for: Android21/31(12.0) 5.4.284+ 4KB ARMv7; libc++180000; Clang18.0.4 ... NDK27.3.13750724. Smart TV TCL TCL

app-full-log.txt

mdk-extract.txt

Full MDK debug log (SetGlobalOption("logLevel","all")) and the corrupted-frame
screenshot available on request — happy to capture whatever traces help.

Activity

  1. wang-bin commented on Jun 28, 2026

    @wang-bin
    Owner

    the log is incomplete

  2. self-assigned this
    on Jun 28, 2026
  3. abdelaziz-mahdy commented on Jun 28, 2026

    @abdelaziz-mahdy
    ContributorAuthor

    sorry yeah it was incomplete
    Added here
    Image

    fvp-capture-full.log

    fvp-capture-mdk.log

  4. wang-bin commented on Jun 29, 2026

    @wang-bin
    Owner

    can you show me the full log for FFmpeg software decoder?

  5. abdelaziz-mahdy commented on Jul 1, 2026

    @abdelaziz-mahdy
    ContributorAuthor

    Sorry for the delay getting back to the TV. I updated fvp to the latest and rebuilt with the latest MDK SDK (FVP_DEPS_LATEST=1), then re-tested.

    Versions

    • fvp 0.37.3
    • MDK 0.37.0 (git f24275a) — banner: Build for: Android21/31(12.0) … NDK27.3.13750724; Jul 1 2026
    • FFmpeg runtime git-2026-06-21-ff1e1b5-avbuild

    Result: still corrupted with both decoders (screenshots unchanged from before). Since software decode corrupts too, this points at the MDK GL renderer / EGLImage texture path on PowerVR, not the decoder. Relevant driver errors in the logs:

    • E IMGSRV: IsTextureConsistent: IMGEGLImage is not consistent
    • E IMGSRV: DevmemAcquireCpuVirtAddr() failed (PVRSRV_ERROR_DEVICEMEM_MAP_FAILED) / Failed to lock buffer

    First log config — software FFmpeg decoder
    fvp.registerWith(options: {'video.decoders': ['FFmpeg']});
    → log confirms opening ffmpeg video decoder: h264 / yuv420p using avcodec software decoder
    fvp-ffmpeg.log

    Second log config — default / hardware decoder
    fvp.registerWith(); (Android default priority ['AMediaCodec', 'FFmpeg', 'dav1d'])
    → log confirms creating video decoder: AMediaCodec
    fvp-normal.log

  6. wang-bin commented on Jul 2, 2026

    @wang-bin
    Owner

    can you see the same driver error log when using libmpv?

  7. abdelaziz-mahdy commented on Jul 8, 2026

    @abdelaziz-mahdy
    ContributorAuthor

    Yes — but it splits into two different errors, and the split is the interesting part.

    I ran the same stream through media_kit (libmpv, mpv vo_gpu renderer) on the exact same device/GPU, where it renders correctly, and compared the logs against the fvp/MDK runs from my previous comment:

    DevmemAcquireCpuVirtAddr() failed (PVRSRV_ERROR_DEVICEMEM_MAP_FAILED) / lock: Failed to lock buffer
    → Same error appears with libmpv too (hundreds of times). It's logged by the PowerVR driver service process (IMGSRV, pid ~401), not the app process, and it shows up even though libmpv renders perfectly. So this one looks like benign/background driver noise, unrelated to the corruption.

    IsTextureConsistent: IMGEGLImage is not consistent
    → Does NOT appear with libmpv (0 occurrences). It only shows up with fvp/MDK, and it's logged inside the app process (same pid as the player) during MDK's EGLImage texture path. This is the one that tracks with the corrupted output.

    Error fvp/MDK (corrupt) libmpv/media_kit (correct) logged by
    DevmemAcquireCpuVirtAddr … MAP_FAILED / Failed to lock buffer yes yes driver service (IMGSRV pid ~401)
    IsTextureConsistent: IMGEGLImage is not consistent yes (app pid) no app process (MDK)

    So the driver-service errors are shared, but the IMGEGLImage is not consistent one is unique to MDK's texture path.

    (Full libmpv logcat available if you want it.)

  8. wang-bin commented on Jul 10, 2026

    @wang-bin
    Owner

    the result from fable 5:
    fvp-374-analysis-zh.html
    fvp-374-analysis-zh.md

    seems reasonable, you can try to add putenv("EGL_SDR_DEPTH=8"); or putenv("GL_BPC=8"); in JNI_OnLoad() in fvp_plugin.cpp, if it works, i will try to find a better solution to detect 10bit surface support. Can you enable mpv log? I have to confirm the output format used by mpv is 8bit.

  9. abdelaziz-mahdy commented on Jul 11, 2026

    @abdelaziz-mahdy
    ContributorAuthor

    EGL_SDR_DEPTH=8 fixes it — added via putenv() in JNI_OnLoad(), rebuilt, same device and streams (default AMediaCodec zero-copy path):

    I/MDK: 0.37.0 (git b345e19) - Multimedia Development Kit.
    [mdk] FINE: select a 8bits EGLConfig
    [mdk] FINE: EGL_NATIVE_VISUAL_ID: 1        // previously: 10bits → visual id 43 (RGBA_1010102)
    [mdk] FINE: player 1st video frame rendered @194.036000ms
    
    • IsTextureConsistent: IMGEGLImage is not consistent — 0 occurrences over full playback (previously fired at first bind)
    • IMGSRV now allocates the window buffers as fmt:0xc101 (8888 + vendor bits); no 0xc12b (1010102) allocations anywhere
    • Picture is completely clean on all decoders, no stutter, seek/resume normal

    Re mpv's output format — verbose log (msg-level=all=v) on the same device/stream:

    [vo/gpu/opengl] v: Initializing GPU context 'android'
    [vo/gpu/opengl] v: GL_RENDERER='PowerVR B-Series BXE-4-32'
    [vo/gpu] v: Reported display depth: 8
    

    mpv takes the driver's first ≥8-bit config (RGBA_8888) and never enters the 1010102 path — its buffers also allocate as fmt:0xc101/0x1 with zero consistency errors.

    Could fvp expose this on Android — setRenderAPI() with GLRenderAPI.depth = 8 like the Windows D3D11 path, ideally as a registerWith option? Happy to test any patch on this device.

  10. wang-bin commented on Jul 11, 2026

    @wang-bin
    Owner

    I see mpv default is 8bit, flutter default is 8bit too, it's fine here. You can try to add these lines before player->updateNativeSurface(surface, w, h);

    mdk::GLRenderAPI ra{};
    ra.depth = 8;
    player->setRenderAPI(&ra, surface);

    An ideal approach is detecting whether rgb10a2 is well supported by driver, but egl accepts this format w/o error.

  11. abdelaziz-mahdy commented on Jul 11, 2026

    @abdelaziz-mahdy
    ContributorAuthor

    We shipped a slightly different workaround on the app side and it works well: setting the env var before the Flutter engine loads any native libs, in MainActivity.onCreate():

    Os.setenv("EGL_SDR_DEPTH", "8", true)

    Since then: select a 8bits EGLConfig, zero IsTextureConsistent errors, clean playback on all decoders.

    Happy to turn your setRenderAPI(depth = 8) snippet into a PR — though unconditional 8-bit would cost 10-bit/HDR output on devices where rgb10a2 works fine, so it probably wants to be opt-in or detected.

    On detection — since the failure only shows when a second GL context samples the buffer (EGL reports no error at config/alloc/render time), a query can't catch it, but a one-time probe can: render a known gradient into an RGBA_1010102 ImageReader surface from one EGL context, import the buffer as an EGLImage in a second context, read back and compare, and pick depth = 8 only on mismatch. That can live entirely in fvp_plugin.cpp before updateNativeSurface(), cached after first run. I'm happy to implement and test it (this device reliably reproduces the failure) if you'd take it as a follow-up PR.

  12. wang-bin commented on Jul 12, 2026

    @wang-bin
    Owner

    Can you try eglChooseConfig with the following attributes

    #define EGL_WARN(x, ...) EGL_RUN_CHECK(x)
    #define EGL_RUN_CHECK(x, ...) do { \
            while (eglGetError() != EGL_SUCCESS) {} \
            (x); \
            const EGLint err = eglGetError(); \
            if (err != EGL_SUCCESS) { \
                std::clog << #x " EGL ERROR (" << std::hex << err << std::dec << ") @" << __LINE__ << __FUNCTION__ << std::endl; \
                __VA_ARGS__; \
            } \
        } while(false)
    
    EGLint ca[] = { 
      EGL_CONFIG_CAVEAT, EGL_NONE,  // default is EGL_DONT_CARE and may select slow config
      EGL_BUFFER_SIZE, 32, 
      EGL_RED_SIZE, 10, 
      EGL_GREEN_SIZE, 10,
      EGL_BLUE_SIZE, 10,
      EGL_ALPHA_SIZE, 2,
      EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT,
      EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
      EGL_NONE
    };
    
        EGLint nb_cfgs; // eglGetConfigs
        vector<EGLConfig> cfgs; // sort by best match(and highest depth?)
        EGLBoolean ret = EGL_FALSE;
        EGL_WARN( ret = eglChooseConfig(disp, ca, nullptr, 0, &nb_cfgs));
    // log ret and nb_cfgs
        if (ret == EGL_FALSE || nb_cfgs < 1) {
          ....
        }

    in libmdk, EGL_CONFIG_CAVEAT is not set, so may get a bad config. if set to EGL_NONE and see error log from EGL_WARN(), then we can use this solution. You can also try EGL_CONFORMANT attribute

  13. wang-bin commented on Jul 13, 2026

    @wang-bin
    Owner

    my phone only accepts EGL_DONT_CARE and EGL_NON_CONFORMANT_CONFIG for EGL_CONFIG_CAVEAT. can you test EGL_NONE, EGL_NON_CONFORMANT_CONFIG and EGL_SLOW_CONFIG?

  14. abdelaziz-mahdy commented on Jul 13, 2026

    @abdelaziz-mahdy
    ContributorAuthor

    my phone only accepts EGL_DONT_CARE and EGL_NON_CONFORMANT_CONFIG for EGL_CONFIG_CAVEAT. can you test EGL_NONE, EGL_NON_CONFORMANT_CONFIG and EGL_SLOW_CONFIG?

    Will give it a try later in the week and let you know, sorry I have one TV and testing on it takes time 😁

  15. abdelaziz-mahdy commented on Jul 18, 2026

    @abdelaziz-mahdy
    ContributorAuthor

    tried your eglChooseConfig suggestion on the tv, results are exactly what you hoped:

    • all RGBA_1010102 window configs on this driver are marked EGL_CONFIG_CAVEAT = EGL_NON_CONFORMANT_CONFIG (conformant=0x0), while all the 8888 ones are EGL_NONE + conformant ES2|ES3
    • your exact query with EGL_CONFIG_CAVEAT, EGL_NONE + 10/10/10/2: ret=true matches=0 and no egl error
    • adding EGL_CONFORMANT = ES2|ES3: also 0 matches

    so the driver self-reports the broken 10bit configs. if libmdk pins EGL_CONFIG_CAVEAT=EGL_NONE it auto falls back to 8888 here and keeps 10bit on good devices — no probe, no env var needed

    config dump from the device (EGL 1.5, Android META-EGL, 64 configs total):

    config id=1..18  rgba=8888     caveat=NONE            conformant=0x45  renderable=0x45
    config id=64..69 rgba=1010102  caveat=NON_CONFORMANT  conformant=0x0   renderable=0x45
    eglChooseConfig(1010102, CAVEAT=NONE):        ret=true matches=0 err=EGL_SUCCESS
    eglChooseConfig(+CONFORMANT=ES2|ES3):         ret=true matches=0 err=EGL_SUCCESS
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions