mylisabox / flutter_mjpeg

Flutter widget to show mjpeg stream from URL
BSD 2-Clause "Simplified" License
30 stars 23 forks source link

A ValueNotifier<bool> was used after being disposed #6

Closed kylethedeveloper closed 4 years ago

kylethedeveloper commented 4 years ago

Hi,

I am routing to my widget which has Mjpeg, my stream works excellent. However when I pop to the previous screen, I get this error. It routes back fine but I don't want errors in my app and this looks like a pretty serious one.


════════ Exception caught by scheduler library ════════
The following assertion was thrown during a task callback:
A ValueNotifier<bool> was used after being disposed.

Once you have called dispose() on a ValueNotifier<bool>, it can no longer be used.
When the exception was thrown, this was the stack: 
#0      ChangeNotifier._debugAssertNotDisposed.<anonymous closure> (package:flutter/src/foundation/change_notifier.dart:105:9)
#1      ChangeNotifier._debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:111:6)
#2      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:200:12)
#3      ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:273:5)
#4      Mjpeg.build.<anonymous closure> (package:flutter_mjpeg/src/mjpeg.dart:84:17)
...

This exception was thrown in the context of a scheduler callback. When the scheduler callback was _registered_ (as opposed to when the exception was thrown), this was the stack: 
#0      new _TaskEntry.<anonymous closure> (package:flutter/src/scheduler/binding.dart:63:31)
#1      new _TaskEntry (package:flutter/src/scheduler/binding.dart:65:6)
#2      SchedulerBinding.scheduleTask (package:flutter/src/scheduler/binding.dart:398:33)
#3      VisibilityDetectorLayer._handleTimer (package:flutter_widgets/src/visibility_detector/src/visibility_detector_layer.dart:199:10)
#12     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:384:19)
...```
jaumard commented 4 years ago

Hello,

Strange, never got that one before. I'm checking if the widget is visible or not to automatically stop the stream if the widget is not on the screen. But here look like the visibility change and called when the notifier is already disposed...

Would be nice if you have a small project that reproduce that error, it will help me find out what's wrong.

Can you also give me your flutter version too please

kylethedeveloper commented 4 years ago

My project is a little bit complicated. I am struggling with this error for about 3 hours and couldn't figure out how to solve.

You can check my source code over here. This is where I use Mjpeg widget and pop route goes to Home.

My flutter version is 1.12.13+hotfix.9.

Ask me if you need any information, I would love this problem to be resolved as I am really happy with your widget.

Edit: This line is Future<bool> instead of void. That's a typo.

jaumard commented 4 years ago

Fix under 1.2.7 :) thanks for the report and test

YowFung commented 4 years ago

Hi, @kylethedeveloper! I have the same problem and I have posted another issue (#8 ) before I saw this issue. I used version 1.2.9 but it remains...

kylethedeveloper commented 4 years ago

@YowFung I don't have information about the details of this widget so I am not the right person to help :disappointed: I once encountered an issue but now, I don't really remember. @jaumard is really helpful and I hope you can solve it!