-
Notifications
You must be signed in to change notification settings - Fork 63
Fix fast refresh for PG #454
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 fast refresh for PG #454
Conversation
Do we really want to tear down and re-create bgfx/graphics on fast refresh? Fast refresh is meant to enable a very fast dev inner loop, and be able to quickly show incremental changes. If we re-create bgfx/graphics, is that noticeably slower and/or disruptive to the dev inner loop? Also, regarding the UpdateView not getting called after a fast refresh... the way the code is currently written, creating a ReactNativeEngine instance must be deferred until graphics is initialized, which in turn must be deferred until there is a window. But if in the case of fast refresh we already have a window (and it is reusable), then it seems like we just need to adjust the code to have the graphics initialization be triggered by something else and see there is already a window to use. I could see doing something like:
Then if we don't have a window yet, async graphics init will need to wait. If we already have a window, then it will just continue on and init if needed. |
@ryantrem yes, fast refresh could be faster without bgfx re-init. It needs a separate issue/PR. |
Before this PR: initPromise was created in resetView. But the promise was checked here
BabylonReactNative/Modules/@babylonjs/react-native/ReactNativeEngine.ts
Line 20 in fb054db
fix: When asked to reset the view from the JS side, reset the Promise.
Note for fast refresh:
When a fast refresh is asked, the view is unchanged meaning
UpdateView
is not called. As the promise is resolved inUpdateView
, rendering will stop.To fix that, I've added a
m_resetDone
boolean that gets true whenresetView
is called and rendering is disabled. As rendering continues, this boolean is check to effectivelyUpdateView
with the last know window configuration.