solid-software / flutter_vlc_player

📺 Flutter VLC powered video player.
506 stars 247 forks source link

UI Stuck When dispose controller #400

Open tabassumLatif opened 1 year ago

tabassumLatif commented 1 year ago

When we play M3U8 video and dispose player it take too much time and stuck the applicaiton. Some sample M3U8 url metions below:

https://media.streambrothers.com:1936/8248/8248/playlist.m3u8 (around 30 seconds) https://597f64b67707a.streamlock.net/alkerazatv.org/alkerazatv.smil/playlist.m3u8 https://cloudvideo.servers10.com:8081/8108/index.m3u8

Please solve this issue.

Logs:

I/CCodecConfig( 6118): query failed after returning 15 values (BAD_INDEX) W/Codec2Client( 6118): query -- param skipped: index = 1073743886. W/Codec2Client( 6118): query -- param skipped: index = 1610614798. D/CCodecBufferChannel( 6118): [c2.exynos.h264.decoder#278] MediaCodec discarded an unknown buffer D/CCodecBufferChannel( 6118): [c2.exynos.h264.decoder#278] MediaCodec discarded an unknown buffer D/CCodecBufferChannel( 6118): [c2.exynos.h264.decoder#278] MediaCodec discarded an unknown buffer D/CCodecBufferChannel( 6118): [c2.exynos.h264.decoder#278] MediaCodec discarded an unknown buffer D/SurfaceUtils( 6118): disconnecting from surface 0xb400007df8cb1e40, reason disconnectFromSurface D/MediaCodec( 6118): flushMediametrics I/hw-BpHwBinder( 6118): onLastStrongRef automatically unlinking death recipients D/BufferPoolAccessor2.0( 6118): bufferpool2 0xb400007d58cba558 : 0(0 size) total buffers - 0(0 size) used buffers - 0/4 (recycle/alloc) - 7/174 (fetch/transfer) D/AudioTrack( 6118): stop(410): called with 0 frames delivered D/BufferPoolAccessor2.0( 6118): bufferpool2 0xb400007d58cba558 : 0(0 size) total buffers - 0(0 size) used buffers - 0/4 (recycle/alloc) - 7/174 (fetch/transfer) D/BufferPoolAccessor2.0( 6118): evictor expired: 1, evicted: 1 I/VLC ( 6118): [b400007d38b8dfa0/1978] libvlc demux: Ending demuxer stream. [needrestart] I/Choreographer( 6118): Skipped 629 frames! The application may be doing too much work on its main thread.

b99andla commented 10 months ago

I also have this problem. Running a livestream from internet and get the MediaCodec discarded an unknown buffer message, then the video stops.

Did you find a solution?

2 E/FrameEvents(12468): updateAcquireFence: Did not find frame. D/AudioTrack(12468): stop(55): called with 7065121 frames delivered 2 E/FrameEvents(12468): updateAcquireFence: Did not find frame. D/EGL_emulation(12468): app_time_stats: avg=41.33ms min=24.61ms max=50.42ms count=25 3 E/FrameEvents(12468): updateAcquireFence: Did not find frame. E/MediaCodec(12468): Pending dequeue output buffer request cancelled I/CCodecConfig(12468): query failed after returning 12 values (BAD_INDEX) D/CCodecConfig(12468): c2 config diff is c2::u32 coded.vui.color.matrix = 1 D/CCodecConfig(12468): c2::u32 coded.vui.color.primaries = 1 D/CCodecConfig(12468): c2::u32 coded.vui.color.transfer = 3 W/Codec2Client(12468): query -- param skipped: index = 1342179345. W/Codec2Client(12468): query -- param skipped: index = 2415921170. W/Codec2Client(12468): query -- param skipped: index = 1610614798. 4 D/CCodecBufferChannel(12468): [c2.goldfish.h264.decoder#502] MediaCodec discarded an unknown buffer D/SurfaceUtils(12468): disconnecting from surface 0xb400007d8cf2ec60, reason disconnectFromSurface I/hw-BpHwBinder(12468): onLastStrongRef automatically unlinking death recipients D/MediaCodec(12468): flushMediametrics D/AudioTrack(12468): stop(55): called with 0 frames delivered E/FrameEvents(12468): updateAcquireFence: Did not find frame.

Walker-ZHAO commented 5 months ago

Same problem. In my case, I play with some flv URLs, like: https://zvp-new.wenjiang.aishangxue.online:60443/rtp/3B9B0584.live.flv

It's a live stream, but in fact, the url's video content is only about 50 seconds long. After play finished, the connection status is complete. But the VlcPlayerValue.playingState is still PlayingState.playingin the listener, and the callback are called continuously.

This is my listener:

void listener() async {
    logger.e('on vlc event:${_controller.value}');
    if (!mounted) return;

    if (_controller.value.isInitialized) {
      var oPosition = _controller.value.position;
      var oDuration = _controller.value.duration;
      if (oDuration.inHours == 0) {
        var strPosition = oPosition.toString().split('.')[0];
        var strDuration = oDuration.toString().split('.')[0];
        position = "${strPosition.split(':')[1]}:${strPosition.split(':')[2]}";
        duration = "${strDuration.split(':')[1]}:${strDuration.split(':')[2]}";
      } else {
        position = oPosition.toString().split('.')[0];
        duration = oDuration.toString().split('.')[0];
      }
      validPosition = oDuration.compareTo(oPosition) >= 0;
      sliderValue = validPosition ? oPosition.inSeconds.toDouble() : 0;
      setState(() {});
    }
}
...
_controller.addListener(listener);

Right output: on vlc event:VlcPlayerValue(duration: 0:00:00.000000, size: Size(1920.0, 1080.0), position: 0:00:58.535000, playingState: PlayingState.ended, isInitialized true, isPlaying: false, isLooping: false, isBuffering: false, isEnded: true, isRecording: false, bufferPercent: 100.0, volume: 100, playbackSpeed: 1.0, audioTracksCount: 2, activeAudioTrack: 1, spuTracksCount: 0, activeSpuTrack: -1, recordPath: , errorDescription: )

Wrong output: on vlc event:VlcPlayerValue(duration: 0:00:00.000000, size: Size(1920.0, 1080.0), position: 0:00:59.802000, playingState: PlayingState.playing, isInitialized true, isPlaying: true, isLooping: false, isBuffering: false, isEnded: false, isRecording: false, bufferPercent: 100.0, volume: 100, playbackSpeed: 1.0, audioTracksCount: 2, activeAudioTrack: 1, spuTracksCount: 0, activeSpuTrack: -1, recordPath: , errorDescription: )

When face right output, dispose player via VlcPlayerController.dispose() works fine. When face wrong output(and this logs are generated continuously with the same content), dispose player via VlcPlayerController.dispose() will stuck the application, I can't interactive with app anymore.

I try many times to test, about 90+% to face the wrong output, and in this case I must kill the app, and try again.

Walker-ZHAO commented 5 months ago

I face this issue only on iOS platform(17.4).

On Android platform, everything works fine.