-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
useEffect hooks do not seem to synchronize with XAML's render pass #9505
Comments
@acoates-ms fyi; does this sound familiar? |
This sounds to me like the batch of commands hasn't been flushed to the compositor yet. XAML's state in memory will reflect what will be there once that happens, but if the expectation of
@asklar This sounds familiar but I couldn't find the issue. Is there a known issue with the dependency script in this configuration? |
@chrisglein re: wmic not working - this is not an issue with the dependencies script but with the RN core CLI - react-native-community/cli#1513 arising from the removal of WMIC from Windows 11 onwards. |
useEffect does not, on any platform, synchronize with native render. It instead is called when the component is mounted into the React Tree, which happens much earlier. |
@NickGerleman thank you for that clarification. In addition to the doc snippet where it mentions "committed to the screen", later it calls out that it fires "after the browser has painted". Should that be considered a doc bug on the ReactJS side I should follow up on? |
It gets a little messy. A lot of the public documentation for react targets In There's a prop on native components, There's some good discussion on the issue of synchronizing JS controlled behavior here. #9292 . Notably a lot of what I said is something that will change in the future, with Fabric, React Native's new UI architecture. |
This is a great resource for Fabric: https://reactnative.dev/docs/render-pipeline |
Two things here:
To our understanding, RNW's |
@asklar Is this still something that makes sense for 0.69 or should it be moved to 0.70? Or maybe the Backlog? |
backlog seems ok; @chswan any objections? |
Problem Description
The React documentation for useEffect states:
In my observation this does not seem to be the case today. Specifically, it looks like at the moment useEffect fires, the XAML tree has been updated but XAML has not itself run a render pass against its tree.
This is impactful because it makes it difficult to show a new top-level window containing RNW content without flickering -- I can't determine "OK, now is a good time to call ShowWindow(SW_SHOW)".
Granted: I believe that XAML doesn't currently expose its render state in a way that would allow this to be implemented to spec. I'm hoping this project can help push to prioritize any prerequisite functionality from XAML.
Steps To Reproduce
Note: I was reproducing this in as close to a release configuration as possible, loading a Hermes bundle from disk, with everything possible built in Release mode. I reproduced this myself with a kernel debugger to catch the DebugBreak because that's what I had handy. There are probably other ways to do this like setting a breakpoint in an existing module implementation that you likewise call from
useEffect()
rather than a custom module with an embedded DebugBreak, I just went with what was easy.breakIntoDebugger()
, whose implementation callsDebugBreak()
.ReactRootView
on-demand in response to a XAML button click (so that you can clearly see the behavior after the app's window is onscreen) and loads a simple React componentuseEffect()
hook and call thebreakIntoDebugger()
native module function inside of it.Expected Results
Expected: the Hello World content is on screen
Actual: the Hello World content is not yet on screen. I sometimes see blank UI and sometimes see the "Bundle Loading" UI. However, analyzing the state of the XAML tree reveals that the Hello World content is there.
CLI version
6.3.1
Environment
Target Platform Version
No response
Target Device(s)
Desktop
Visual Studio Version
No response
Build Configuration
Release
Snack, code example, screenshot, or link to a repository
Sorry, I do not have a publicly shareable minimal repro right now. MSFT people, please reach out to me and I can share what I have.
The text was updated successfully, but these errors were encountered: