Code Monkey home page Code Monkey logo

Comments (37)

alexmercerind avatar alexmercerind commented on May 24, 2024 1

Thanks for the clarification. The example application also seems to crash for some reason (it didn't earlier) when playing two videos simultaneously. I will fix issues like this & it is the primary reason I haven't published the plugin yet. I will hold accountability for stability. I need some time.


I'm actually busy with my semester examinations till the end of this month.
I will make further advancements & implementation(s) for other platforms after returning.

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024 1

It's invalid memory access or access violation as I said. I'm not super sure about what could be causing it.

I will try fixing tomorrow & begin working on linux implementation.

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

Remove any dispose calls.

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024

Unfortunately it still does. I have made a widget with the media_kit included. I call this widget multiple times.

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

A better clarification will be provided with the stacktrace of the crash. Use Visual Studio to do it (for debug build).

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024

Thank you! Much appreciated.

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

Ping @Quackdoc:

For me, this glFinish is crashing with invalid memory access. The invalid memory access is taking place within the ANGLE DLL. I'm not sure about this one (at the moment), maybe this could be due to wrong usage or syncing issue?

I attempted to use single mutex for all VideoOutputs, the crash still takes place when playing multiple videos.
Try using the last section of the example application, where 2 videos can be played side by side.


EDIT:

from media-kit.

Quackdoc avatar Quackdoc commented on May 24, 2024

hmm, im getting sigterm even without that glfinish.


EDIT1; yeah even without any of the glfinishes, if I start one video, then swap between the other ones with a somewhat moderate speed, the program just closes. vscode isnt providing anything useful, maybe I have it misconfigured
EDIT2;

Its certainly a GL issue since forcing S/W rendering doesn't have any of the issues at all.

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

A workaround is to pass fixed size from VideoController.create for now.

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

Hi @GideonKock,

I've made a fix. Please try it out (confirmation is needed to keep the track), it shouldn't crash anymore.

NOTE: Flutter 3.7.x+ is needed from now on (beta or master channel at the time). This was partially due to bugs in Flutter itself.

You can download the test application for a quick look: https://github.com/alexmercerind/media_kit/suites/10371871389/artifacts/511589023 . Select last option for playing 2 videos at once. AFAIK crash triggered when size of video changed or played for the first time. Your feedback after compiling/running your own application is also welcomed. It should work fine too.

media_kit_test_fCkNB17CKX

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

@GideonKock any feedback?

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024

I'm still testing, but after upgrading the package, my own application still crashes with the same error, with and without dispose calls. I will do some tests and provide more information.

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

Make sure that the package is actually updated. Git dependencies in pubspec.yaml generally don't sync.

You should specify ref: 36b0681c61fcfe7283b07d7d4b67c8554e080e7b (for both packages) as-well. Then, flutter pub get.

dependencies:
  media_kit:
    git: https://github.com/alexmercerind/media_kit.git
    path: media_kit
    ref: 36b0681c61fcfe7283b07d7d4b67c8554e080e7b
  media_kit_core_video:
    git: https://github.com/alexmercerind/media_kit.git
    path: media_kit_core_video
    ref: 36b0681c61fcfe7283b07d7d4b67c8554e080e7b

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

And be on master/beta channel.

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024

I'm getting the following error:

Scherm­afbeelding 2023-01-16 om 10 53 46

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

And be on master/beta channel.

^^

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024

Sorry, I was running on the stable channel. But after a flutter clean and pub get I get the following message:

image

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

Sorry, I was running on the stable channel. But after a flutter clean and pub get I get the following message:

image

Please update ref to latest.

The links to one of dependencies was changed. Sorry won't happen again.

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024

It's working :). Only with a material app. Unfortunately I use Fluent_ui and I get errors related to this packege when I'm on the master channel. Any suggestions?

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024

Unfortunately the issue still occur. I have made an example. See the code below. The error only accurs with a valid url.

The error occurs after switching tabs a couple of times.

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024
import 'package:flutter/material.dart';
import 'package:media_kit/media_kit.dart';
import 'package:media_kit_video/media_kit_video.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int currentPageIndex = 0;
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
            primarySwatch: Colors.blue, scaffoldBackgroundColor: Colors.blue),
        home: DefaultTabController(
          length: 2,
          child: Scaffold(
            appBar: const TabBar(
              tabs: [
                Tab(icon: Icon(Icons.directions_car)),
                Tab(icon: Icon(Icons.directions_transit)),
              ],
            ),
            body: TabBarView(
              children: [
                Wrap(
                  children: [
                    for (int i = 0; i < 1; i++) ...[
                      SizedBox(height: 500, width: 500, child: MyScreen())
                    ]
                  ],
                ),
                Wrap(
                  children: [
                    for (int i = 0; i < 2; i++) ...[
                      SizedBox(height: 500, width: 500, child: MyScreen())
                    ]
                  ],
                ),
              ],
            ),
          ),
        ));
  }
}

class MyScreen extends StatefulWidget {
  const MyScreen({Key? key}) : super(key: key);
  @override
  State<MyScreen> createState() => _MyScreenState();
}

class _MyScreenState extends State<MyScreen> {
  final Player player = Player();
  VideoController? controller;

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      controller = await VideoController.create(
        player.handle,
      );
      player.open(Playlist(
        [
          Media(
              'https://....:[email protected]:55756/Acs/Streaming/Video/Live/Mp4/?camera=27074_196f745a-87e5-4325-ba5b-cda2d12026e7&quality=medium&audio=0'),
        ],
      ));
      setState(() {});
    });
  }

  @override
  void dispose() {
    Future.microtask(() async {
      // Release allocated resources back to the system.
      await controller?.dispose();
      await player.dispose();
    });
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Video(
      filterQuality: FilterQuality.high,
      controller: controller,
    );
  }
}

from media-kit.

Quackdoc avatar Quackdoc commented on May 24, 2024

you are disposing the controller

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

Can't reproduce. Present more details, what is the extent & what is the cause.
Use Visual Studio to generate stack-trace.

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024

Yes, this was mentioned in the example on the mainpage. So I only have to dispose the player?

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

Yes, this was mentioned in the example on the mainpage. So I only have to dispose the player?

What makes you so sure that your async calls to create/dispose don't cause some conflict when changing tabs very-very quickly i.e. dispose being called before WidgetsBinding.instance.addPostFrameCallback completes? The test application is playing/creating/disposing 4 videos simultaneously without any races or access violations etc.

C++ isn't for kids. It doesn't kindly inform you about invalid memory accesses with a nice message.
A debugger works here e.g. devenv or Visual Studio.

https://gist.github.com/loic-sharma/248f28b3ba4664dde08da68f46b312bd

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024

Without disposing the controller the error no longer appears.

With disposing the controller, the error appears when choosing the other tab and then back. Also when switch tabs slowly.

I've used the debugger in Visual Studio as you mentioned. I hope this is the information you need:

image

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

@GideonKock, try out the latest changes on 5bf3a17.

Specify ref as 5bf3a17cdb8d68cc5b43141d791b27cac837a4e9 in your pubspec.yaml for both packages.

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

There was an issue within my implementation of releasing EGL resources inside ANGLESurfaceManager destructor.
Now calling dispose won't crash (and it's important to release resources, please don't remove it).


Still, I'm facing few very rare crashes within libGLESv2.dll through libmpv-2.dll when dragging through tabs using my track-pad in a fast manner & there's very little that can be done. Let's see what can I do.

EDIT: Only happening when dispose is present.


A GOOD IDEA WILL BE TO manage your VideoController & Player efficiently instead of depending on initState etc.

Example:

Create one Player & VideoController outside the tab viewer & use it for displaying video in every tab. It will be more performant & avoid initialization delays as well.

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

I'd appreciate response though. Any improvements?

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

GOOD NEWS!

I could fix that as well. No more crashes!

Checkout to 5bf3a17 & specify ref as 5bf3a17cdb8d68cc5b43141d791b27cac837a4e9 in your pubspec.yaml.


Also, I added a new screen to test application for simulating this scenario & deal with future implementations:

Whole day wasted! 🥳🥳🥳

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024

Nice! Sorry, but I’m not able tot test it today. Will do it tomorrow. But it seems very good. Much appriciated!

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

Any feedback?

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024

In my own application it still crashes. Only difference compared to the example application is that I use multiple streams at one tab. Will test it tomorrow in the example application.

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

Best practice will be to maintain the Player & VideoController instances outside of Tabs & only pass their reference into the widgets. It will give you not only finer control over lifecycle but improve performance as you can possibly use already created Players within multiple tabs (as previous one automatically gets hidden).

from media-kit.

GideonKock avatar GideonKock commented on May 24, 2024

Thanks, will try to implement. Multiple video's in a tab in your test application works without errors.

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

I tried running your exact same example above & I see literally zero crashes, it's so stable.

from media-kit.

alexmercerind avatar alexmercerind commented on May 24, 2024

FYI stability has been further improved for Windows in latest media_kit: ^0.0.2 & media_kit_video: ^0.0.2 (upgrade both).

from media-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.