androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.74k stars 416 forks source link

ExoPlayer does not render fully with AndroidView #1354

Closed lilemma closed 6 months ago

lilemma commented 6 months ago

Version

Media3 main branch

More version details

Hi, I am having issues using the ExoPlayer. I don't believe we always had the issue, but we started experiencing the video not rendering fully.

The screenshots from a Pixel 7 Pro shows the video rendering black when the app is in foreground, and rendering transparent when the app moves to background. Screenshot_20240508-111345 Screenshot_20240508-112004

Those devices where the bug does not appear, it always gets rendered correctly.

I have not been able to reproduce the issue in the demo app.

Implementation

Box(
        modifier = modifier
            .fillMaxSize()
            .onGloballyPositioned {
                screenHeight = it.size.height
            }

    ) {
    val player = remember {
        buildPlayer(..

val playerView = remember {
        PlayerView(context).apply {
            useController = false
            resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
            this.player = player
            this.clipToOutline = true
        }
    }

    AndroidView(
        factory = {
            playerView
        },
        update = { view ->
            view.layoutParams = view.layoutParams.apply { height = screenHeight }
            view.requestLayout()
        }
    )
    }

Log from the app while the bug occurred:


2024-05-08 10:45:11.137 31624-529   TrafficStats            com.test.app                D  tagSocket(235) with statsTag=0xffffffff, statsUid=-1
2024-05-08 10:45:11.510 31624-527   DMCodecAdapterFactory   com.test.app                I  Creating an asynchronous MediaCodec adapter for track type video
2024-05-08 10:45:11.514 31624-543   CCodec                  com.test.app                D  allocate(c2.exynos.h264.decoder)
2024-05-08 10:45:11.516 31624-543   CCodec                  com.test.app                I  setting up 'default' as default (vendor) store
2024-05-08 10:45:11.518 31624-543   CCodec                  com.test.app                I  Created component [c2.exynos.h264.decoder]
2024-05-08 10:45:11.519 31624-543   CCodecConfig            com.test.app                D  read media type: video/avc
2024-05-08 10:45:11.520 31624-543   ReflectedParamUpdater   com.test.app                D  extent() != 1 for single value type: output.subscribed-indices.values
2024-05-08 10:45:11.520 31624-543   ReflectedParamUpdater   com.test.app                D  extent() != 1 for single value type: input.buffers.allocator-ids.values
2024-05-08 10:45:11.520 31624-543   ReflectedParamUpdater   com.test.app                D  extent() != 1 for single value type: output.buffers.allocator-ids.values
2024-05-08 10:45:11.521 31624-543   ReflectedParamUpdater   com.test.app                D  extent() != 1 for single value type: output.buffers.pool-ids.values
2024-05-08 10:45:11.522 31624-543   ReflectedParamUpdater   com.test.app                D  ignored struct field coded.color-format.locations
2024-05-08 10:45:11.524 31624-543   CCodecConfig            com.test.app                D  ignoring local param raw.size (0xd2001800) as it is already supported
2024-05-08 10:45:11.524 31624-543   CCodecConfig            com.test.app                D  ignoring local param default.color (0x5200180b) as it is already supported
2024-05-08 10:45:11.524 31624-543   ReflectedParamUpdater   com.test.app                D  ignored struct field raw.hdr-static-info.mastering
2024-05-08 10:45:11.525 31624-543   CCodecConfig            com.test.app                I  query failed after returning 15 values (BAD_INDEX)
2024-05-08 10:45:11.525 31624-543   CCodecConfig            com.test.app                D  c2 config diff is Dict {
                                                                                                      c2::u32 algo.low-latency.value = 0
                                                                                                      c2::i32 algo.priority.value = 0
                                                                                                      c2::float algo.rate.value = 0
                                                                                                      c2::u32 coded.pl.level = 20496
                                                                                                      c2::u32 coded.pl.profile = 20481
                                                                                                      c2::u32 coded.vui.color.matrix = 0
                                                                                                      c2::u32 coded.vui.color.primaries = 0
                                                                                                      c2::u32 coded.vui.color.range = 0
                                                                                                      c2::u32 coded.vui.color.transfer = 0
                                                                                                      c2::u32 default.color.matrix = 0
                                                                                                      c2::u32 default.color.primaries = 0
                                                                                                      c2::u32 default.color.range = 0
                                                                                                      c2::u32 default.color.transfer = 0
                                                                                                      c2::u32 input.buffers.max-size.value = 7340032
                                                                                                      string input.media-type.value = "video/avc"
                                                                                                      c2::u32 output.delay.value = 3
                                                                                                      string output.media-type.value = "video/raw"
                                                                                                      c2::u32 raw.color.matrix = 0
                                                                                                      c2::u32 raw.color.primaries = 0
                                                                                                      c2::u32 raw.color.range = 0
                                                                                                      c2::u32 raw.color.transfer = 0
                                                                                                      c2::float raw.hdr-static-info.max-cll = 0
                                                                                                      c2::float raw.hdr-static-info.max-fall = 0
                                                                                                      c2::u32 raw.max-size.height = 240
                                                                                                      c2::u32 raw.max-size.width = 320
                                                                                                      c2::u32 raw.pixel-format.value = 34
                                                                                                      c2::i32 raw.rotation.flip = 
2024-05-08 10:45:11.525 31624-543   ColorUtils              com.test.app                W  expected specified color aspects (0:0:0:0)
2024-05-08 10:45:11.529 31624-538   MediaCodec              com.test.app                I  MediaCodec will operate in async mode
2024-05-08 10:45:11.530 31624-538   SurfaceUtils            com.test.app                D  connecting to surface 0xb4000075f985cc30, reason connectToSurface
2024-05-08 10:45:11.530 31624-538   MediaCodec              com.test.app                I  [c2.exynos.h264.decoder] setting surface generation to 32382986
2024-05-08 10:45:11.530 31624-538   SurfaceUtils            com.test.app                D  disconnecting from surface 0xb4000075f985cc30, reason connectToSurface(reconnect)
2024-05-08 10:45:11.530 31624-538   SurfaceUtils            com.test.app                D  connecting to surface 0xb4000075f985cc20, reason connectToSurface(reconnect-with-listener)
2024-05-08 10:45:11.530 31624-543   CCodec                  com.test.app                D  [c2.exynos.h264.decoder] buffers are bound to CCodec for this session
2024-05-08 10:45:11.531 31624-543   CCodecConfig            com.test.app                D  no c2 equivalents for log-session-id
2024-05-08 10:45:11.531 31624-543   CCodecConfig            com.test.app                D  no c2 equivalents for color-standard
2024-05-08 10:45:11.531 31624-543   CCodecConfig            com.test.app                D  no c2 equivalents for csd-1
2024-05-08 10:45:11.531 31624-543   CCodecConfig            com.test.app                D  no c2 equivalents for native-window
2024-05-08 10:45:11.531 31624-543   CCodecConfig            com.test.app                D  no c2 equivalents for native-window-generation
2024-05-08 10:45:11.531 31624-543   CCodecConfig            com.test.app                D  no c2 equivalents for flags
2024-05-08 10:45:11.531 31624-543   CCodecConfig            com.test.app                D  c2 config diff is   c2::u32 default.color.matrix = 1
                                                                                                      c2::u32 default.color.primaries = 1
                                                                                                      c2::u32 default.color.range = 2
                                                                                                      c2::u32 default.color.transfer = 3
                                                                                                      c2::u32 raw.max-size.height = 1350
                                                                                                      c2::u32 raw.max-size.width = 1080
                                                                                                      c2::u32 raw.size.height = 1350
                                                                                                      c2::u32 raw.size.width = 1080
2024-05-08 10:45:11.531 31624-543   Codec2Client            com.test.app                W  query -- param skipped: index = 1107298332.
2024-05-08 10:45:11.531 31624-543   CCodec                  com.test.app                D  client requested max input size 322471, which is smaller than what component recommended (7340032); overriding with component recommendation.
2024-05-08 10:45:11.531 31624-543   CCodec                  com.test.app                W  This behavior is subject to change. It is recommended that app developers double check whether the requested max input size is in reasonable range.
2024-05-08 10:45:11.531 31624-543   CCodec                  com.test.app                D  encoding statistics level = 0
2024-05-08 10:45:11.531 31624-543   CCodec                  com.test.app                D  setup formats input: AMessage(what = 0x00000000) = {
                                                                                                      int32_t height = 1350
                                                                                                      int32_t level = 65536
                                                                                                      int32_t max-input-size = 7340032
                                                                                                      string mime = "video/avc"
                                                                                                      int32_t priority = 0
                                                                                                      int32_t profile = 65536
                                                                                                      int32_t width = 1080
                                                                                                      Rect crop(0, 0, 1079, 1349)
                                                                                                    }
2024-05-08 10:45:11.532 31624-543   CCodec                  com.test.app                D  setup formats output: AMessage(what = 0x00000000) = {
                                                                                                      int32_t android._color-format = 2130708361
                                                                                                      int32_t android._video-scaling = 1
                                                                                                      int32_t rotation-degrees = 0
                                                                                                      int32_t color-standard = 1
                                                                                                      int32_t color-range = 2
                                                                                                      int32_t color-transfer = 3
                                                                                                      float cta861.max-cll = 0.000000
                                                                                                      float cta861.max-fall = 0.000000
                                                                                                      int32_t sar-height = 1
                                                                                                      int32_t sar-width = 1
                                                                                                      Rect crop(0, 0, 1079, 1349)
                                                                                                      int32_t width = 1080
                                                                                                      int32_t height = 1350
                                                                                                      int32_t max-height = 1350
                                                                                                      int32_t max-width = 1080
                                                                                                      string mime = "video/raw"
                                                                                                      int32_t priority = 0
                                                                                                      int32_t android._dataspace = 260
                                                                                                      int32_t color-format = 2130708361
                                                                                                    }
2024-05-08 10:45:11.532 31624-543   CCodecConfig            com.test.app                I  query failed after returning 15 values (BAD_INDEX)
2024-05-08 10:45:11.532 31624-543   CCodecConfig            com.test.app                D  c2 config diff is   c2::u32 raw.color.matrix = 1
                                                                                                      c2::u32 raw.color.primaries = 1
                                                                                                      c2::u32 raw.color.range = 2
                                                                                                      c2::u32 raw.color.transfer = 3
2024-05-08 10:45:11.532 31624-527   MediaCodec              com.test.app                D  keep callback message for reclaim
2024-05-08 10:45:11.541 31624-543   Codec2Client            com.test.app                W  query -- param skipped: index = 1073743886.
2024-05-08 10:45:11.541 31624-543   Codec2Client            com.test.app                W  query -- param skipped: index = 1610614798.
2024-05-08 10:45:11.541 31624-543   CCodecBufferChannel     com.test.app                D  [c2.exynos.h264.decoder#804] Created input block pool with allocatorID 16 => poolID 23 - OK (0)
2024-05-08 10:45:11.542 31624-543   CCodecBufferChannel     com.test.app                I  [c2.exynos.h264.decoder#804] Created output block pool with allocatorID 18 => poolID 33 - OK
2024-05-08 10:45:11.542 31624-543   CCodecBufferChannel     com.test.app                D  [c2.exynos.h264.decoder#804] Configured output block pool ids 33 => OK
2024-05-08 10:45:11.542 31624-543   Codec2-Out...ufferQueue com.test.app                D  remote graphic buffer migration 0/0
2024-05-08 10:45:11.542 31624-543   Codec2Client            com.test.app                D  setOutputSurface -- failed to set consumer usage (6/BAD_INDEX)
2024-05-08 10:45:11.542 31624-543   Codec2Client            com.test.app                D  setOutputSurface -- generation=32382986 consumer usage=0x900
2024-05-08 10:45:11.544 31624-543   Codec2Client            com.test.app                D  Surface configure completed
2024-05-08 10:45:11.547 31624-32502 BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb4000076897aae38 : 0(0 size) total buffers - 0(0 size) used buffers - 541/548 (recycle/alloc) - 6/547 (fetch/transfer)
2024-05-08 10:45:11.547 31624-32502 BufferPoolAccessor2.0   com.test.app                D  Destruction - bufferpool2 0xb4000076897aae38 cached: 0/0M, 0/0% in use; allocs: 548, 99% recycled; transfers: 547, 99% unfetched
2024-05-08 10:45:11.548 31624-32502 BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb4000076897aabe8 : 0(0 size) total buffers - 0(0 size) used buffers - 524/532 (recycle/alloc) - 6/534 (fetch/transfer)
2024-05-08 10:45:11.548 31624-527   DMCodecAdapterFactory   com.test.app                I  Creating an asynchronous MediaCodec adapter for track type audio
2024-05-08 10:45:11.548 31624-32502 BufferPoolAccessor2.0   com.test.app                D  Destruction - bufferpool2 0xb4000076897aabe8 cached: 0/0M, 0/0% in use; allocs: 532, 98% recycled; transfers: 534, 99% unfetched
2024-05-08 10:45:11.550 31624-579   CCodec                  com.test.app                D  allocate(c2.android.aac.decoder)
2024-05-08 10:45:11.551 31624-579   CCodec                  com.test.app                I  setting up 'default' as default (vendor) store
2024-05-08 10:45:11.553 31624-579   CCodec                  com.test.app                I  Created component [c2.android.aac.decoder]
2024-05-08 10:45:11.553 31624-579   CCodecConfig            com.test.app                D  read media type: audio/mp4a-latm
2024-05-08 10:45:11.554 31624-543   CCodecConfig            com.test.app                D  c2 config diff is   c2::u32 output.delay.value = 7
2024-05-08 10:45:11.555 31624-579   ReflectedParamUpdater   com.test.app                D  extent() != 1 for single value type: algo.buffers.max-count.values
2024-05-08 10:45:11.555 31624-579   ReflectedParamUpdater   com.test.app                D  extent() != 1 for single value type: output.subscribed-indices.values
2024-05-08 10:45:11.555 31624-579   ReflectedParamUpdater   com.test.app                D  extent() != 1 for single value type: input.buffers.allocator-ids.values
2024-05-08 10:45:11.555 31624-579   ReflectedParamUpdater   com.test.app                D  extent() != 1 for single value type: output.buffers.allocator-ids.values
2024-05-08 10:45:11.555 31624-543   Codec2-Out...ufferQueue com.test.app                D  set max dequeue count 14 from update
2024-05-08 10:45:11.555 31624-579   ReflectedParamUpdater   com.test.app                D  extent() != 1 for single value type: algo.buffers.allocator-ids.values
2024-05-08 10:45:11.555 31624-579   ReflectedParamUpdater   com.test.app                D  extent() != 1 for single value type: output.buffers.pool-ids.values
2024-05-08 10:45:11.555 31624-579   ReflectedParamUpdater   com.test.app                D  extent() != 1 for single value type: algo.buffers.pool-ids.values
2024-05-08 10:45:11.556 31624-32502 CCodecBufferChannel     com.test.app                D  [c2.exynos.h264.decoder#804] Ignoring stale input buffer done callback: last flush index = 0, frameIndex = 0
2024-05-08 10:45:11.557 31624-543   Codec2-Out...ufferQueue com.test.app                D  set max dequeue count 14 from update
2024-05-08 10:45:11.557 31624-543   Codec2-Out...ufferQueue com.test.app                D  set max dequeue count 14 from update
2024-05-08 10:45:11.558 31624-579   CCodecConfig            com.test.app                I  query failed after returning 20 values (BAD_INDEX)
2024-05-08 10:45:11.558 31624-579   CCodecConfig            com.test.app                D  c2 config diff is Dict {
                                                                                                      c2::u32 coded.aac-packaging.value = 0
                                                                                                      c2::u32 coded.bitrate.value = 64000
                                                                                                      c2::u32 coded.pl.level = 0
                                                                                                      c2::u32 coded.pl.profile = 8192
                                                                                                      c2::i32 coding.drc.album-mode.value = 0
                                                                                                      c2::float coding.drc.attenuation-factor.value = 1
                                                                                                      c2::float coding.drc.boost-factor.value = 1
                                                                                                      c2::i32 coding.drc.compression-mode.value = 3
                                                                                                      c2::i32 coding.drc.effect-type.value = 3
                                                                                                      c2::float coding.drc.encoded-level.value = 0.25
                                                                                                      c2::float coding.drc.reference-level.value = -16
                                                                                                      c2::u32 input.buffers.max-size.value = 8192
                                                                                                      c2::u32 input.delay.value = 0
                                                                                                      string input.media-type.value = "audio/mp4a-latm"
                                                                                                      c2::u32 output.delay.value = 2
                                                                                                      c2::float output.drc.output-loudness.value = 0.25
                                                                                                      string output.media-type.value = "audio/raw"
                                                                                                      c2::u32 raw.channel-count.value = 1
                                                                                                      c2::u32 raw.channel-mask.value = 0
                                                                                                      c2::u32 raw.max-channel-count.value = 8
                                                                                                      c2::u32 raw.sample-rate.value = 44100
                                                                                                    }
2024-05-08 10:45:11.560 31624-579   MediaCodec              com.test.app                I  MediaCodec will operate in async mode
2024-05-08 10:45:11.561 31624-579   CCodec                  com.test.app                D  [c2.android.aac.decoder] buffers are bound to CCodec for this session
2024-05-08 10:45:11.561 31624-579   CCodecConfig            com.test.app                D  no c2 equivalents for log-session-id
2024-05-08 10:45:11.561 31624-579   CCodecConfig            com.test.app                D  no c2 equivalents for flags
2024-05-08 10:45:11.562 31624-579   CCodecConfig            com.test.app                D  config failed => CORRUPTED
2024-05-08 10:45:11.562 31624-579   CCodecConfig            com.test.app                D  c2 config diff is   c2::u32 raw.channel-count.value = 2
                                                                                                      c2::u32 raw.sample-rate.value = 48000
2024-05-08 10:45:11.563 31624-579   Codec2Client            com.test.app                W  query -- param skipped: index = 1107298332.
2024-05-08 10:45:11.563 31624-579   CCodec                  com.test.app                D  client requested max input size 942, which is smaller than what component recommended (8192); overriding with component recommendation.
2024-05-08 10:45:11.563 31624-579   CCodec                  com.test.app                W  This behavior is subject to change. It is recommended that app developers double check whether the requested max input size is in reasonable range.
2024-05-08 10:45:11.563 31624-579   CCodec                  com.test.app                D  encoding statistics level = 0
2024-05-08 10:45:11.563 31624-579   CCodec                  com.test.app                D  setup formats input: AMessage(what = 0x00000000) = {
                                                                                                      int32_t aac-drc-album-mode = 0
                                                                                                      int32_t aac-drc-boost-level = 127
                                                                                                      int32_t aac-drc-cut-level = 127
                                                                                                      int32_t aac-drc-effect-type = 3
                                                                                                      int32_t aac-encoded-target-level = -1
                                                                                                      int32_t aac-max-output-channel_count = 8
                                                                                                      int32_t aac-target-ref-level = 64
                                                                                                      int32_t bitrate = 64000
                                                                                                      int32_t channel-count = 2
                                                                                                      int32_t channel-mask = 0
                                                                                                      int32_t level = 0
                                                                                                      int32_t max-input-size = 8192
                                                                                                      int32_t max-output-channel-count = 8
                                                                                                      string mime = "audio/mp4a-latm"
                                                                                                      int32_t profile = 2
                                                                                                      int32_t sample-rate = 48000
                                                                                                    }
2024-05-08 10:45:11.563 31624-579   CCodec                  com.test.app                D  setup formats output: AMessage(what = 0x00000000) = {
                                                                                                      int32_t aac-drc-album-mode = 0
                                                                                                      int32_t aac-drc-boost-level = 127
                                                                                                      int32_t aac-drc-cut-level = 127
                                                                                                      int32_t aac-drc-effect-type = 3
                                                                                                      int32_t aac-drc-output-loudness = -1
                                                                                                      int32_t aac-encoded-target-level = -1
                                                                                                      int32_t aac-max-output-channel_count = 8
                                                                                                      int32_t aac-target-ref-level = 64
                                                                                                      int32_t channel-count = 2
                                                                                                      int32_t channel-mask = 0
                                                                                                      int32_t max-output-channel-count = 8
                                                                                                      string mime = "audio/raw"
                                                                                                      int32_t sample-rate = 48000
                                                                                                      int32_t android._config-pcm-encoding = 2
                                                                                                    }
2024-05-08 10:45:11.564 31624-579   CCodecConfig            com.test.app                I  query failed after returning 20 values (BAD_INDEX)
2024-05-08 10:45:11.564 31624-527   MediaCodec              com.test.app                D  keep callback message for reclaim
2024-05-08 10:45:11.565 31624-579   Codec2Client            com.test.app                W  query -- param skipped: index = 1342179345.
2024-05-08 10:45:11.565 31624-579   Codec2Client            com.test.app                W  query -- param skipped: index = 2415921170.
2024-05-08 10:45:11.565 31624-579   Codec2Client            com.test.app                W  query -- param skipped: index = 1610614798.
2024-05-08 10:45:11.565 31624-579   CCodecBufferChannel     com.test.app                D  [c2.android.aac.decoder#686] Created input block pool with allocatorID 16 => poolID 24 - OK (0)
2024-05-08 10:45:11.566 31624-32502 BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb400007689797168 : 0(0 size) total buffers - 0(0 size) used buffers - 1008/1013 (recycle/alloc) - 9/1003 (fetch/transfer)
2024-05-08 10:45:11.566 31624-32502 BufferPoolAccessor2.0   com.test.app                D  Destruction - bufferpool2 0xb400007689797168 cached: 0/0M, 0/0% in use; allocs: 1013, 100% recycled; transfers: 1003, 99% unfetched
2024-05-08 10:45:11.566 31624-579   CCodecBufferChannel     com.test.app                I  [c2.android.aac.decoder#686] Created output block pool with allocatorID 16 => poolID 46 - OK
2024-05-08 10:45:11.566 31624-32502 BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb4000076897914e8 : 0(0 size) total buffers - 0(0 size) used buffers - 988/993 (recycle/alloc) - 5/979 (fetch/transfer)
2024-05-08 10:45:11.566 31624-32502 BufferPoolAccessor2.0   com.test.app                D  Destruction - bufferpool2 0xb4000076897914e8 cached: 0/0M, 0/0% in use; allocs: 993, 99% recycled; transfers: 979, 99% unfetched
2024-05-08 10:45:11.566 31624-579   CCodecBufferChannel     com.test.app                D  [c2.android.aac.decoder#686] Configured output block pool ids 46 => OK
2024-05-08 10:45:11.583 31624-579   CCodecConfig            com.test.app                D  c2 config diff is   c2::u32 raw.channel-mask.value = 12
2024-05-08 10:45:11.583 31624-579   CCodecBuffers           com.test.app                D  [c2.android.aac.decoder#686:Output[N]] popFromStashAndRegister: at 1000000000000us, output format changed to AMessage(what = 0x00000000) = {
                                                                                                      int32_t aac-drc-album-mode = 0
                                                                                                      int32_t aac-drc-boost-level = 127
                                                                                                      int32_t aac-drc-cut-level = 127
                                                                                                      int32_t aac-drc-effect-type = 3
                                                                                                      int32_t aac-drc-output-loudness = -1
                                                                                                      int32_t aac-encoded-target-level = -1
                                                                                                      int32_t aac-max-output-channel_count = 8
                                                                                                      int32_t aac-target-ref-level = 64
                                                                                                      int32_t channel-count = 2
                                                                                                      int32_t channel-mask = 12
                                                                                                      int32_t max-output-channel-count = 8
                                                                                                      string mime = "audio/raw"
                                                                                                      int32_t sample-rate = 48000
                                                                                                      int32_t android._config-pcm-encoding = 2
                                                                                                    }
2024-05-08 10:45:11.583 31624-543   CCodecConfig            com.test.app                D  c2 config diff is   c2::u32 raw.crop.height = 1350
                                                                                                      c2::u32 raw.crop.left = 0
                                                                                                      c2::u32 raw.crop.top = 0
                                                                                                      c2::u32 raw.crop.width = 1080
                                                                                                      c2::u32 raw.max-size.height = 1360
                                                                                                      c2::u32 raw.max-size.width = 1088
                                                                                                      c2::u32 raw.size.height = 1360
                                                                                                      c2::u32 raw.size.width = 1088
2024-05-08 10:45:11.583 31624-543   CCodecBuffers           com.test.app                D  [c2.exynos.h264.decoder#804:2D-Output] popFromStashAndRegister: at 1000000000000us, output format changed to AMessage(what = 0x00000000) = {
                                                                                                      int32_t android._color-format = 2130708361
                                                                                                      int32_t android._video-scaling = 1
                                                                                                      int32_t rotation-degrees = 0
                                                                                                      int32_t color-standard = 1
                                                                                                      int32_t color-range = 2
                                                                                                      int32_t color-transfer = 3
                                                                                                      float cta861.max-cll = 0.000000
                                                                                                      float cta861.max-fall = 0.000000
                                                                                                      int32_t sar-height = 1
                                                                                                      int32_t sar-width = 1
                                                                                                      Rect crop(0, 0, 1079, 1349)
                                                                                                      int32_t width = 1088
                                                                                                      int32_t height = 1360
                                                                                                      int32_t max-height = 1360
                                                                                                      int32_t max-width = 1088
                                                                                                      string mime = "video/raw"
                                                                                                      int32_t priority = 0
                                                                                                      int32_t android._dataspace = 260
                                                                                                      int32_t color-format = 2130708361
                                                                                                    }
2024-05-08 10:45:12.294 31624-31633 test.app         com.test.app                I  Background concurrent mark compact GC freed 401047(20MB) AllocSpace objects, 452(92MB) LOS objects, 56% free, 72MB/168MB, paused 1.565ms,3.550ms total 152.079ms
2024-05-08 10:45:16.744 31624-32502 BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb4000076897792b8 : 5(36700160 size) total buffers - 5(36700160 size) used buffers - 140/145 (recycle/alloc) - 5/145 (fetch/transfer)
2024-05-08 10:45:16.949 31624-579   BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb40000768979cb98 : 5(40960 size) total buffers - 1(8192 size) used buffers - 268/273 (recycle/alloc) - 5/272 (fetch/transfer)
2024-05-08 10:45:17.543 31624-32501 BufferPoolAccessor2.0   com.test.app                D  evictor expired: 4, evicted: 0
2024-05-08 10:45:21.915 31624-32502 BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb4000076897792b8 : 5(36700160 size) total buffers - 5(36700160 size) used buffers - 269/274 (recycle/alloc) - 5/274 (fetch/transfer)
2024-05-08 10:45:22.473 31624-579   BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb40000768979cb98 : 5(40960 size) total buffers - 1(8192 size) used buffers - 527/532 (recycle/alloc) - 5/531 (fetch/transfer)
2024-05-08 10:45:27.063 31624-32502 BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb4000076897792b8 : 5(36700160 size) total buffers - 5(36700160 size) used buffers - 398/403 (recycle/alloc) - 5/406 (fetch/transfer)
2024-05-08 10:45:27.794 31624-579   BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb40000768979cb98 : 5(40960 size) total buffers - 1(8192 size) used buffers - 776/781 (recycle/alloc) - 5/780 (fetch/transfer)
2024-05-08 10:45:32.210 31624-527   AudioTrack              com.test.app                D  stop(127): called with 1000448 frames delivered
2024-05-08 10:45:32.701 31624-527   MediaCodec              com.test.app                D  keep callback message for reclaim
2024-05-08 10:45:32.702 31624-538   CCodecConfig            com.test.app                I  query failed after returning 15 values (BAD_INDEX)
2024-05-08 10:45:32.702 31624-538   BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb4000076897792b8 : 5(36700160 size) total buffers - 1(7340032 size) used buffers - 520/525 (recycle/alloc) - 5/530 (fetch/transfer)
2024-05-08 10:45:32.705 31624-538   Codec2Client            com.test.app                W  query -- param skipped: index = 1073743886.
2024-05-08 10:45:32.705 31624-538   Codec2Client            com.test.app                W  query -- param skipped: index = 1610614798.
2024-05-08 10:45:32.709 31624-527   MediaCodec              com.test.app                D  keep callback message for reclaim
2024-05-08 10:45:32.710 31624-579   CCodecConfig            com.test.app                I  query failed after returning 20 values (BAD_INDEX)
2024-05-08 10:45:32.711 31624-579   Codec2Client            com.test.app                W  query -- param skipped: index = 1342179345.
2024-05-08 10:45:32.711 31624-579   Codec2Client            com.test.app                W  query -- param skipped: index = 2415921170.
2024-05-08 10:45:32.712 31624-579   Codec2Client            com.test.app                W  query -- param skipped: index = 1610614798.
2024-05-08 10:45:33.290 31624-538   SurfaceUtils            com.test.app                D  connecting to surface 0xb4000075f97cbff0, reason connectToSurface
2024-05-08 10:45:33.290 31624-538   MediaCodec              com.test.app                I  [c2.exynos.h264.decoder] setting surface generation to 32382987
2024-05-08 10:45:33.291 31624-538   SurfaceUtils            com.test.app                D  disconnecting from surface 0xb4000075f97cbff0, reason connectToSurface(reconnect)
2024-05-08 10:45:33.291 31624-538   SurfaceUtils            com.test.app                D  connecting to surface 0xb4000075f97cbfe0, reason connectToSurface(reconnect-with-listener)
2024-05-08 10:45:33.291 31624-538   Codec2-Out...ufferQueue com.test.app                D  remote graphic buffer migration 0/0
2024-05-08 10:45:33.291 31624-538   Codec2Client            com.test.app                D  setOutputSurface -- failed to set consumer usage (6/BAD_INDEX)
2024-05-08 10:45:33.291 31624-538   Codec2Client            com.test.app                D  setOutputSurface -- generation=32382987 consumer usage=0x900
2024-05-08 10:45:33.293 31624-538   Codec2Client            com.test.app                D  Surface configure completed
2024-05-08 10:45:33.293 31624-538   SurfaceUtils            com.test.app                D  disconnecting from surface 0xb4000075f985cc30, reason disconnectFromSurface
2024-05-08 10:45:33.303 31624-31624 ExoPlayerImpl           com.test.app                I  Release a1ef47a [AndroidXMedia3/1.3.1] [cheetah, Pixel 7 Pro, Google, 34] [media3.common, media3.exoplayer, media3.decoder, media3.ui, media3.datasource, media3.extractor]
2024-05-08 10:45:33.305 31624-538   CCodecBufferChannel     com.test.app                D  [c2.exynos.h264.decoder#804] MediaCodec discarded an unknown buffer
2024-05-08 10:45:33.305 31624-538   CCodecBufferChannel     com.test.app                D  [c2.exynos.h264.decoder#804] MediaCodec discarded an unknown buffer
2024-05-08 10:45:33.306 31624-527   MediaCodec              com.test.app                D  keep callback message for reclaim
2024-05-08 10:45:33.306 31624-538   CCodecConfig            com.test.app                I  query failed after returning 15 values (BAD_INDEX)
2024-05-08 10:45:33.308 31624-538   Codec2Client            com.test.app                W  query -- param skipped: index = 1073743886.
2024-05-08 10:45:33.308 31624-538   Codec2Client            com.test.app                W  query -- param skipped: index = 1610614798.
2024-05-08 10:45:33.311 31624-527   MediaCodec              com.test.app                D  keep callback message for reclaim
2024-05-08 10:45:33.311 31624-579   CCodecConfig            com.test.app                I  query failed after returning 20 values (BAD_INDEX)
2024-05-08 10:45:33.311 31624-579   BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb40000768979cb98 : 5(40960 size) total buffers - 1(8192 size) used buffers - 984/989 (recycle/alloc) - 5/979 (fetch/transfer)
2024-05-08 10:45:33.312 31624-579   Codec2Client            com.test.app                W  query -- param skipped: index = 1342179345.
2024-05-08 10:45:33.312 31624-579   Codec2Client            com.test.app                W  query -- param skipped: index = 2415921170.
2024-05-08 10:45:33.312 31624-579   Codec2Client            com.test.app                W  query -- param skipped: index = 1610614798.
2024-05-08 10:45:33.314 31624-538   SurfaceUtils            com.test.app                D  connecting to surface 0xb4000075f983ef50, reason connectToSurface
2024-05-08 10:45:33.315 31624-538   MediaCodec              com.test.app                I  [c2.exynos.h264.decoder] setting surface generation to 32382988
2024-05-08 10:45:33.315 31624-538   SurfaceUtils            com.test.app                D  disconnecting from surface 0xb4000075f983ef50, reason connectToSurface(reconnect)
2024-05-08 10:45:33.315 31624-538   SurfaceUtils            com.test.app                D  connecting to surface 0xb4000075f983ef40, reason connectToSurface(reconnect-with-listener)
2024-05-08 10:45:33.315 31624-538   Codec2-Out...ufferQueue com.test.app                D  remote graphic buffer migration 0/0
2024-05-08 10:45:33.315 31624-538   Codec2Client            com.test.app                D  setOutputSurface -- failed to set consumer usage (6/BAD_INDEX)
2024-05-08 10:45:33.315 31624-538   Codec2Client            com.test.app                D  setOutputSurface -- generation=32382988 consumer usage=0x900
2024-05-08 10:45:33.317 31624-538   Codec2Client            com.test.app                D  Surface configure completed
2024-05-08 10:45:33.317 31624-538   SurfaceUtils            com.test.app                D  disconnecting from surface 0xb4000075f97cbff0, reason disconnectFromSurface
2024-05-08 10:45:33.317 31624-538   CCodecBufferChannel     com.test.app                D  [c2.exynos.h264.decoder#804] MediaCodec discarded an unknown buffer
2024-05-08 10:45:33.318 31624-538   CCodecBufferChannel     com.test.app                D  [c2.exynos.h264.decoder#804] MediaCodec discarded an unknown buffer
2024-05-08 10:45:33.318 31624-538   CCodecBufferChannel     com.test.app                D  [c2.exynos.h264.decoder#804] MediaCodec discarded an unknown buffer
2024-05-08 10:45:33.318 31624-538   CCodecBufferChannel     com.test.app                D  [c2.exynos.h264.decoder#804] MediaCodec discarded an unknown buffer
2024-05-08 10:45:33.327 31624-579   CCodecBufferChannel     com.test.app                D  [c2.android.aac.decoder#686] MediaCodec discarded an unknown buffer
2024-05-08 10:45:33.327 31624-538   SurfaceUtils            com.test.app                D  disconnecting from surface 0xb4000075f983ef50, reason disconnectFromSurface
2024-05-08 10:45:33.327 31624-579   CCodecBufferChannel     com.test.app                D  [c2.android.aac.decoder#686] MediaCodec discarded an unknown buffer
2024-05-08 10:45:33.327 31624-961   hw-BpHwBinder           com.test.app                I  onLastStrongRef automatically unlinking death recipients
2024-05-08 10:45:33.327 31624-579   CCodecBufferChannel     com.test.app                D  [c2.android.aac.decoder#686] MediaCodec discarded an unknown buffer
2024-05-08 10:45:33.327 31624-579   CCodecBufferChannel     com.test.app                D  [c2.android.aac.decoder#686] MediaCodec discarded an unknown buffer
2024-05-08 10:45:33.328 31624-579   hw-BpHwBinder           com.test.app                I  onLastStrongRef automatically unlinking death recipients
2024-05-08 10:45:38.554 31624-32501 BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb40000768979cb98 : 0(0 size) total buffers - 0(0 size) used buffers - 988/993 (recycle/alloc) - 5/979 (fetch/transfer)
2024-05-08 10:45:38.554 31624-32501 BufferPoolAccessor2.0   com.test.app                D  bufferpool2 0xb4000076897792b8 : 0(0 size) total buffers - 0(0 size) used buffers - 527/532 (recycle/alloc) - 5/530 (fetch/transfer)
2024-05-08 10:45:38.554 31624-32501 BufferPoolAccessor2.0   com.test.app                D  evictor expired: 2, evicted: 2```

### Devices that reproduce the issue

* Pixel 6a, Android 14
* Pixel 6 Pro, Android 14

### Devices that do not reproduce the issue

* OnePlus 7Pro

### Reproducible in the demo app?

No

### Reproduction steps

Play the attached media in the demo app

### Expected result

The media plays successfully

### Actual result

The media plays successfully in the demo app

### Media

https://player.vimeo.com/progressive_redirect/playback/629037952/rendition/1080p/1080p.mp4?loc=external&signature=5ea319a940151e66dffea3b750eaf982ffbabece7c2e7fbf9879544cc8e4555e

### Bug Report

- [ ] You will email the zip file produced by `adb bugreport` to android-media-github@google.com after filing this issue.
icbaker commented 6 months ago

Given the usage of compose, this looks like a duplicate of #1237

lilemma commented 6 months ago

You are right, the device is also running version AP1A.240305.019.A1

oceanjules commented 6 months ago

@lilemma, would it be possibly for you to provide full implementation of your MainActivity.kt AND the test media?

On the outset, @icbaker is right and that does look like a duplicate candidate for the issue we've been seeing with Interop Compose (AndroidView) and SurfaceView/AspectRatioFrameLayout interaction. However, we've had a bunch of cases where the rendering of the video can be fixed with correct Modifiers, layout parameters and remember-ing.

lilemma commented 6 months ago

@oceanjules Thanks for the response.

I have a snippet of our MainActivity, MainScreen and NavigationGraph, but I think it will be way to complicated to supply all the implementation from MainActivity to our Player implementation, there are multiple composables, compose-destinations and verticalPager in between.

You mentioned AspectRatioFrameLayout, and I tried changing from AspectRatioFrameLayout.RESIZE_MODE_ZOOM to AspectRatioFrameLayout.RESIZE_MODE_FILL it works, but it's just not the resizeMode I need. Also when I experience the issue, my VideoPlayer is inside a VerticalPager, and when I drag down just a bit, the view gets redrawn, and it shows correctly. If I replace my VerticalPager with a Box, I still experience the rendering issue, so I don't believe it's related to the VerticalPager.

We are using the same VideoPlayer implementation multiple places in the app. When I test the video in one of our implementations which uses a specific aspectRatio and graphicsLayer for the container, it renders as it should.

BoxWithConstraints(
        modifier = Modifier
            .align(Alignment.Center)
            .fillMaxWidth()
            .aspectRatio(3 / 4f)
            .graphicsLayer {
                scaleX = scale.value
                scaleY = scale.value
                translationX = x.value
                translationY = y.value
            }
    ) {

It feels like there is a rendering order issue related to the RESIZE_MODE_ZOOM and aspect ratio

Please let me know if you need more details :)

MainActivity.kt

override fun onCreate(savedInstanceState: Bundle?) {
        installSplashScreen()

        super.onCreate(savedInstanceState)
        onNewIntent(intent)

        if (DeviceProperties.isTablet(resources)) {
            requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
        }

        if (Build.VERSION.SDK_INT in 21..29) {
            window.statusBarColor = Color.TRANSPARENT
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
            window.decorView.systemUiVisibility = SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or SYSTEM_UI_FLAG_LAYOUT_STABLE
            WindowCompat.setDecorFitsSystemWindows(window, false)
        } else if (Build.VERSION.SDK_INT >= 30) {
            window.statusBarColor = Color.TRANSPARENT
            WindowCompat.setDecorFitsSystemWindows(window, false)
        }

        setContent {
            val bottomSheetNavigator = rememberBottomSheetNavigator(skipHalfExpanded = true)

            navController = rememberNavController(bottomSheetNavigator)

            MainScreen(mainViewModel, navController, bottomSheetNavigator)
        }
    }
}

---
MainScreen.kt

@OptIn(ExperimentalAnimationApi::class, ExperimentalComposeUiApi::class)
@Composable
fun MainScreen(
    viewModel: MainViewModel,
    navController: NavHostController,
    bottomSheetNavigator: BottomSheetNavigator
) {
    val scaffoldState = rememberScaffoldState()

    AppTheme {
        // Initialization
        val systemUiController = rememberSystemUiController()
        SideEffect {
            systemUiController.setSystemBarsColor(Color.Transparent, darkIcons = true)
            systemUiController.setNavigationBarColor(AppColor.sand20, darkIcons = true)
            systemUiController.setStatusBarColor(Color.Transparent, darkIcons = true) { Color.Transparent }
        }

                com.google.accompanist.navigation.material.ModalBottomSheetLayout(
                    bottomSheetNavigator = bottomSheetNavigator,
                    sheetShape = RoundedCornerShape(10.dp, 10.dp, 0.dp, 0.dp),
                    modifier = Modifier
                        .navigationBarsPadding()
                        .imePadding()
                        .semantics {
                            testTagsAsResourceId = true
                        },
                ) {
                    Scaffold(
                        modifier = Modifier.semantics {
                            testTagsAsResourceId = true
                        },
                        scaffoldState = scaffoldState,
                        snackbarHost = { scaffoldState.snackbarHostState },
                        bottomBar = { BottomBar(hiltViewModel(), navController) }
                    ) {
                        NavigationGraph(
                            navController = navController,
                            mainViewModel = viewModel,
                            startDestination = MediaGalleryScreenDestination
                        )
                        bottomSheetNavigator.popBackStack()
                    }

                }
    }
}

--
NavigationGraph.kt

@OptIn(ExperimentalMaterialNavigationApi::class)
@ExperimentalAnimationApi
@Composable
fun NavigationGraph(
    navController: NavHostController,
    mainViewModel: MainViewModel,
    startDestination: TypedDestination<*>
) {
    val navHostEngine = rememberAnimatedNavHostEngine(
        rootDefaultAnimations = horizontalScreenTransitions,
    )

    DestinationsNavHost(
        navGraph = NavGraphs.root,
        startRoute = startDestination,
        modifier = Modifier
            .fillMaxSize()
            .background(AppColor.sand10),
        engine = navHostEngine,
        navController = navController,
        dependenciesContainerBuilder = {
        },
        manualComposableCallsBuilder = {
        }
    )
}