flame icon indicating copy to clipboard operation
flame copied to clipboard

Flame race condition on the children API

Open erickzanardo opened this issue 3 years ago • 3 comments

Current bug behaviour

  • Do a test that uses an assets
  • Pre load the asset on the game onLoad
  • Do a test for a component that accesses that asset from the game cache
  • Test is broken because the asset is not loaded yet

Expected behaviour

Test should pass ok because the asset was preloaded

More information

As far as I debugged, this is happening because of a race condition on the flame children API (this is also affecting the FlameBlocProvider as it has a similar API), the children there are added to the game on the component constructor, and their children onLoad happens before the game onLoad method has finished.

Unfortunately I can't link the source code where I can consistently reproduce this, but I will link an example when possible.

erickzanardo avatar May 06 '22 14:05 erickzanardo

We allow the components to load when the game .hasLayout, which could happen before the game is mounted or loaded.

Are you saying no component should start loading before the Game instance is fully loaded?

st-pasha avatar May 06 '22 16:05 st-pasha

Are you saying no component should start loading before the Game instance is fully loaded?

Give this context that I explained, I believe they shouldn't, but I think this is something that we can discuss here.

For me, it is seems confusing that something that we load on the game onLoad method may not be available for components to access on their own onLoad.

erickzanardo avatar May 06 '22 16:05 erickzanardo

Give this context that I explained, I believe they shouldn't, but I think this is something that we can discuss here.

For me, it is seems confusing that something that we load on the game onLoad method may not be available for components to access on their own onLoad.

I must have been lucky not to bump into this, I assumed it did load the game first too, I think it did at some point? 🤔

Maybe we could have it optional that it starts loading components before the game is done loading?

spydon avatar May 08 '22 13:05 spydon