-
-
Notifications
You must be signed in to change notification settings - Fork 953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FutureProvider the ref.onCancel() is called but ref.onDispose() is not #3323
Comments
Please make a minimal reproducible example. I cannot run this code |
Sure, Here it is. https://github.com/MxD-js/riverpod_repro_issue_3323_example |
Hi Guys, I'm following up on this, I've been bashing my head to figure this out.. Any insight into what could be causing this? |
I'm working on other stuff at the moment. I have yet to investigate this. If it's urgent for you, feel free to ask for help on Discord. Otherwise you may have to wait |
Thanks @rrousselGit I'll reach out on discord. |
Does it help to move onDispose before the async/await part? |
Oh sorry I didn't see your answer. Yes, the placement of onDispose is the issue, as you found out yourself. The documentation has already been updated, so I'll close this |
Describe the bug
If a I tap on a item from a ListView and pressed the back button the widget is disposed as expected and the provider ref.onRemoveListener is called then ref.onCancel is called also expected but not ref.onDispose is never called and long after the screen is disposed of the video player plays the video in the background and ref.onDispose is never called to dispose the player.
However when I let the the future provider complete and the data is present in the widget page then dispose functions as expected when the user presses the back button.
This issue comes up because when the user clicks on a video item from a ListView and taps back out immediate after the provider is still in a loading state and even though ref.onCancel was called, ref.onDispose is never called to dispose the video controllers and async functions complete and video starts playing on a unmounted and disposed of widget.
(Pardon all the print statements, just trying to figure out what is going on)
To Reproduce
and my widget for the video player
Terminal output for when it's working correctly.
but when I quickly access the video player page and then press the back button this is the terminal output.
but no ref.onDispose is never called.
Expected behavior
Expect that ref.onDispose is called
The text was updated successfully, but these errors were encountered: