abdelaziz-mahdy / flutter_meedu_videoplayer

Cross-Platform Video Player for flutter
https://abdelaziz-mahdy.github.io/flutter_meedu_videoplayer/
MIT License
144 stars 71 forks source link

App dead freezes on linux with .m3u8 network url #36

Closed Chu-4hun closed 1 year ago

Chu-4hun commented 1 year ago

When dispose() is called, I guess dart_vls is not properly disposed any url with .m3u8 causes crashes code example

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_meedu_videoplayer/meedu_player.dart';

class BasicExamplePage extends StatefulWidget {
  const BasicExamplePage({Key? key}) : super(key: key);

  @override
  _BasicExamplePageState createState() => _BasicExamplePageState();
}

class _BasicExamplePageState extends State<BasicExamplePage> {
  final _meeduPlayerController = MeeduPlayerController(
    controlsStyle: ControlsStyle.primary,
  );

  StreamSubscription? _playerEventSubs;

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      _init();
    });
  }

  @override
  void dispose() {
    _playerEventSubs?.cancel();
    _meeduPlayerController.dispose();
    super.dispose();
  }

  _init() {
    _meeduPlayerController.setDataSource(
      DataSource(
        type: DataSourceType.network,
        source:
            "https://cloud.kodik-storage.com/useruploads/37065397-cf0c-4ea9-9269-718278450c77/8c5f1bd672a7c29b50209c3b5e5cc345:2023032820/360.mp4:hls:manifest.m3u8",
      ),
      autoplay: true,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: SafeArea(
        child: AspectRatio(
          aspectRatio: 16 / 9,
          child: MeeduVideoPlayer(
            controller: _meeduPlayerController,
          ),
        ),
      ),
    );
  }
}
[h264 @ 0x7f5f500ceac0] get_buffer() failed
[h264 @ 0x7f5f500ceac0] thread_get_buffer() failed
[h264 @ 0x7f5f500ceac0] decode_slice_header error
[h264 @ 0x7f5f500ceac0] no frame!
[h264 @ 0x7f5f50012f80] get_buffer() failed
[h264 @ 0x7f5f50012f80] thread_get_buffer() failed
[h264 @ 0x7f5f50012f80] decode_slice_header error
[h264 @ 0x7f5f50012f80] no frame!
abdelaziz-mahdy commented 1 year ago

I am waiting for media_kit new release, when that available I will move to it, due to being much faster and more stable (dart_vlc maintainer is the same as media_kit) so he is working more in media_kit

Also from your logs, I see no problem does the app crash with no indication of the problem?

Chu-4hun commented 1 year ago

Yes it does. Even VS Code thinks that app still running. I'll record behavior.

abdelaziz-mahdy commented 1 year ago

Yes it does. Even VS Code thinks that app still running. I'll record behavior.

Can you test the example code too? Or a video url which is not m3u8?

Chu-4hun commented 1 year ago

Yes it does. Even VS Code thinks that app still running. I'll record behavior.

Can you test the example code too? Or a video url which is not m3u8?

Not .m3u8 links works fine. Code provided above is from example but only url is changed

Chu-4hun commented 1 year ago

Запись экрана от 28.03.2023 12:28:07.webm

abdelaziz-mahdy commented 1 year ago

Yes it does. Even VS Code thinks that app still running. I'll record behavior.

Can you test the example code too? Or a video url which is not m3u8?

Not .m3u8 links works fine. Code provided above is from example but only url is changed

All m3u8 fails right? That's on Linux, I think yes it's related to dart_vlc

Can you wait for media_kit adaptation?

Chu-4hun commented 1 year ago

I need to test this behavior in web. But if media_kit adaptation won't take too long, it will be ok, I just wont build my app to linux and test it on web.

abdelaziz-mahdy commented 1 year ago

I need to test this behavior in web. But if media_kit adaptation won't take too long, it will be ok, I just wont build my app to linux and test it on web.

Okay, let me know if there is anything else.

I will try to do the adaptation ASAP

Chu-4hun commented 1 year ago

Do I need to close the issue, if the problem is still relevant?

abdelaziz-mahdy commented 1 year ago

Do I need to close the issue, if the problem is still relevant?

i think its better to leave it open, since its not fixed yet

abdelaziz-mahdy commented 1 year ago

@Chu-4hun can you test with 4.0.7 ? this version is using media_kit (also supports macos)

Chu-4hun commented 1 year ago

@Chu-4hun can you test with 4.0.7 ? this version is using media_kit (also supports macos)

Ok, let me check

Chu-4hun commented 1 year ago

i tried this dispose method

@override
  void dispose() {
    try {
      _meeduPlayerController.dispose();
    } catch (e) {
      print(e.toString());
    }

    if (!Platform.isLinux) {
      Wakelock.disable();
    }
    super.dispose();
  }

It's still freezes

  [ERROR:flutter/shell/platform/embedder/embedder_external_texture_gl.cc(98)] Could not create external texture->
media_kit: TextureGL: THIS IS NOT AN ERROR. DO NOT REPORT!
[ERROR:flutter/shell/platform/embedder/embedder_external_texture_gl.cc(98)] Could not create external texture->
media_kit: TextureGL: Resize: (640, 426)
flutter: Duration is 0:25:04.869000
flutter: VideoOutput.Resize
flutter: {handle: 93962798065504, id: 93962776366640, rect: {left: 0, top: 0, width: 640, height: 426}}
flutter: Fit is BoxFit.fitWidth
[GETX] CLOSE TO ROUTE /ReleaseView
media_kit: VideoOutput: video_output_dispose: 93962798065504
Chu-4hun commented 1 year ago

i use ubuntu 22.03 with x11 display manager

Chu-4hun commented 1 year ago

i think this can be it media_kit: VideoOutput: video_output_dispose: 140442684142720

abdelaziz-mahdy commented 1 year ago

i think this can be it media_kit: VideoOutput: video_output_dispose: 140442684142720

That is a normal log for media_kit.

Can you test media_kit example? It's on their repo as media_kit_test

  1. Open the first example page
  2. Play with your url
  3. Go back to the main page

If that's crash too, then it's a media_kit problem.

If it doesn't then it's a problem on my side.

Note: I don't have Linux, this is why I am not able to test.

Please let me know what happens.

Chu-4hun commented 1 year ago

https://user-images.githubusercontent.com/70685495/229286533-e5304a9f-d0ad-426a-b70f-b3fe19b6c198.mp4

Chu-4hun commented 1 year ago

still freezes . . .

Chu-4hun commented 1 year ago

Im using flutter 3.7.8 stable branch. I'll try to upgrade to the testing channel

Chu-4hun commented 1 year ago

on flutter 3.9.0-20.0.pre75 i have this error (i know what it is a flutter error, but just to log).

ERROR: ../../../../.pub-cache/hosted/pub.dev/stacked-3.2.0/lib/src/view_models/ui/skeleton_loader.dart:106:19: Error: No named parameter with the name 'vsync'. ERROR: vsync: this,

abdelaziz-mahdy commented 1 year ago

still freezes . . .

Okay, can you open an issue on media_kit package

Since this seems to be a problem on their side

abdelaziz-mahdy commented 1 year ago

on flutter 3.9.0-20.0.pre75 i have this error (i know what it is a flutter error, but just to log).

ERROR: ../../../../.pub-cache/hosted/pub.dev/stacked-3.2.0/lib/src/view_models/ui/skeleton_loader.dart:106:19: Error: No named parameter with the name 'vsync'. ERROR: vsync: this,

For this, I saw a breaking change where they removed vsync, so i guess this is this problem

abdelaziz-mahdy commented 1 year ago

did you open an issue in media_kit or it was fixed?

Chu-4hun commented 1 year ago

did you open an issue in media_kit or it was fixed?

I'm really sorry for my delay. I haven't done it yet. I'm writing my last college thesis and because of this there is not enough time. Furthermore, I will test again my error and will open the issue if needed.

abdelaziz-mahdy commented 1 year ago

did you open an issue in media_kit or it was fixed?

I'm really sorry for my delay. I haven't done it yet. I'm writing my last college thesis and because of this there is not enough time. Furthermore, I will test again my error and will open the issue if needed.

Good luck with that, and thank you very much.

Chu-4hun commented 1 year ago

Updated your library to 4.2.2

flutter_meedu_videoplayer: ^4.2.2

Still crashes on dispose() with linux

abdelaziz-mahdy commented 1 year ago

Updated your library to 4.2.2

flutter_meedu_videoplayer: ^4.2.2

Still crashes on dispose() with linux

Also can you provide flutter doctor output

And run flutter pub update and send ouput of it

And test again, and let me know?

And Does it happen on media_kit test?

If yes, that's on their side so they may require a url to test what causes it and what is the fix for it

Chu-4hun commented 1 year ago

I commented on their issue

https://github.com/alexmercerind/media_kit/issues/167#issuecomment-1528101173

Chu-4hun commented 1 year ago

And Does it happen on media_kit test?

If yes, that's on their side so they may require a url to test what causes it and what is the fix for it

I created the blank project with media_kit. Bug is still relevant. It's on their side.

Chu-4hun commented 1 year ago

Also can you provide flutter doctor output

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.9, on Pop!_OS 22.04 LTS 6.2.6-76060206-generic, locale ru_RU.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] VS Code (version 1.77.3)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.
abdelaziz-mahdy commented 1 year ago

I commented on their issue

https://github.com/alexmercerind/media_kit/issues/167#issuecomment-1528101173

Thank you very much