-
-
Notifications
You must be signed in to change notification settings - Fork 934
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
fix: Adds a check to confirm the component is not loaded #2579
Conversation
@spydon I am going to need some help on this one. The code works fine except for its breaking the Edit: I have confirmed that they (for some reason) do hit the |
Like I wrote on discord (so others can discuss too):
|
I realized late last night that I was being dumb in my implementation and forgot to focus on processLifecycleEvents onDetach. I actually think there is a larger, albeit different issue though and will look at it now. Regardless, it is very interesting that these tests call FlameGame onDetach - I don't think that is expected behavior. |
onDetach
to FlameGame
to prevent orphaned components from throwing errorsonDetach
to FlameGame
to prevent orphaned components from throwing errors
onDetach
to FlameGame
to prevent orphaned components from throwing errorsonDetach
to FlameGame
to prevent orphaned components from throwing errors
onDetach
to FlameGame
to prevent orphaned components from throwing errorsonDetach
to FlameGame
to prevent orphaned components from throwing errors
onDetach
to FlameGame
to prevent orphaned components from throwing errorsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it! Could you add some test for it? :)
Ok everyone, I finally have this solved. I have learned way more about the Flame engine internals than I had ever planned on, lol. To summarise: The issue has nothing to do with what it seemed like on the surface. In short, the |
I don't even know how to begin testing these scenarios. I would think quite the contrary that the existing tests, caught when it was wrong. To test this, you would have to have access to the internals that aren't exposed and you can't assert because its a valid scenario, so honestly, I am at a loss as to where to start. |
You should only have to make sure that |
Test has been added. It's a pretty long test, but it was the only way I could really validate all the states and truly confirm that the game was detached, the child remained, and then when reloaded, onLoad is not happening again and the child is being restored to its state that it was previously as we discussed. So for anyone else reading, the expectation is that when I detach a flame game from the flutter widget tree and then reattach it, everything is exactly as it was prior to being detached. When the game is detached, the gameLoop is disposed. |
Ok, during the testing of the induced failing tests for Tap and Drag callbacks, I learned that when you remove the game from the Flutter widget tree, you aren't removing (unmounting / detaching) the |
Description
This fixes #2563 by validating that a component is mounted and the child component is not mounted before adding it to the queue.
Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Breaking Change?
Related Issues
Closes #2563