-
-
Notifications
You must be signed in to change notification settings - Fork 116
fix: deadlock between FindComponents and updates of rendered components #731
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
Conversation
8c5f74e to
8ffda48
Compare
|
I need to pressure test this more. But after sleeping on this I am more confident in the solution than yesterday |
|
Just to recap why this is a better solution than the lock:
|
|
I guess to some degree also the lock in |
I have been testing the changes with the code RaphaelMarcouxCTRL provided, and did run into another deadlock that was caused by the call to That said, I still think the lock in WaitForHelper is needed, since there is a timer that runs in a different thread that could trigger a clean up/dispose of the WaitForHelper, at the same time as a OnAfterRender check is being processed. |
|
OK, so the latest fix does cause other tests to fail consistently. Ill keep experimenting 🤕 |
Not really, since FindComponents are synchronous all the way through, meaning that it will complete without ever being async. It's just a way for us to schedule the FindComponents call on the same scheduler as the renderer. If you look at Renderer.cs you will see they use a similar trick in there as well.
There is a race condition between the timeout timer and the OnAfterRender updates. But a lock might be too heavy and something else could be used to say "don't dispose while there is an OnAfterRender check in progress, and don't start a OnAfterRender check after dispose has started". |
85cb899 to
b0c300d
Compare
tests/bunit.core.tests/Extensions/WaitForHelpers/RenderedFragmentWaitForHelperExtensionsTest.cs
Show resolved
Hide resolved
878ce64 to
67dc158
Compare
|
Ps. I will rewrite the commit when things looks like they are working |
75a7d46 to
f1fbc88
Compare
|
@linkdotnet I think this is it. Let me know if you can spot anything wrong with this. I could not figure out a way to actually test that the renderer is blocked while FindComponents is doing its thing. Did test it manually by having a component constantly re-render and adding a thread.sleep to FindComponents, and can see that without forcing FindComponents to run in the same context as the renderer, the constant rerendering component doesnt stop. |
|
Good work on this one. Especially the |
f1fbc88 to
856b9a0
Compare
bb5689f to
e3c1902
Compare
fixes #577. The problem is that FindComponents traverses down the render tree when invoked, and this ensures that no renders happens while it does so, without using locks like previous, which could result in deadlocks. fix: aways wrap FindComponentsInternal in Dispatcher fix: optimize wait for logging fix: ensure failure tasks in WaitForHelper run on Renderer schedular
e3c1902 to
7bb24ac
Compare
Fixed #577.
THIS is experimental.
My idea was to, instead of using a lock around the the render tree getting build and find component's traversing the render tree to find components, is to just run the find component logic inside the dispatcher for the renderer. That should ensure that only at the time is allowed to happen.
Pull request description
PR meta checklist
mainbranch for codeor targeted at
stablebranch for documentation that is live on bunit.dev.Code PR specific checklist