-
-
Notifications
You must be signed in to change notification settings - Fork 116
Protecting the render tree #1136
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
f0e1dfe to
e5ac99b
Compare
linkdotnet
left a comment
There 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.
Overall I have mixed feelings about the PR. It adds quite some complexity and coupling to the code base. This is fine in theory, but I am not sure if we just tackle the symptom or the root cause of the stack overflow - I am leaning much toward the "symptom" site.
Don't get me wrong, I do think that there might be a bug in our code base causing this - given that the user sees no problem when running his code in the browser.
The circumstances of the bug make it awful hard to debug. Just my two cents
I'm pretty certain there is a bug. The stack traces that have been shared with us show the bug in two places, 1. when we traverse through the render tree frames of each rendered component from UpdateDisplay and 2. in RenderEvent when deciding if a rendered component or its children have changed during a render. After fixing it in the first place, the second showed up, and the stack overflow visible from the stack trace pointed at the second position. My assumption has always been that calls to The code we had previously did something like this and that overflowed. I do play to ask the Blazor team to clarify my assumptions: private void CanStackOverflow(int componentId)
{
var frames = GetCurrentRenderTreeFrames(componentId);
for (var i = 0; i < frames.Count; i++)
{
ref var frame = ref frames.Array[i];
if (frame.FrameType == RenderTreeFrameType.Component)
{
CanStackOverflow(frame.ComponentId);
}
}
}I agree this is not the prettiest code and I am open to any and all improvements you can suggest. The requirement, at least for the v1 code, is that the RenderEvent type needs to be able to answer whether or not a RenderedCompnent has been disposed or needs to have its Markup re-created. And it should return the render tree frames for each component and child component associated with the RenderedComponent (used by Htmlizer) when the markup is recreated. Pinged the Blazor team and asked for help understanding the render tree frames: dotnet/aspnetcore#49138 |
|
Btw. I want to rewrite a bunch of this logic in V2, suspect we can drop having RenderEvent entirely, so a lot of the complexity also comes out of being none breaking from an API point of view. |
I am very open to alternatives. Any good idea what other things that could cause this? |
I dug in the code yesterday for an hour - but I am not really smarter. It might be about shared state between test runs. Without any real and reproducible code, it is very hard to pinpoint the issue. |
|
Yeah, and it was/is something that was sensitive to him enabling logging. I am fairly certain that part of this is due to renders happening after the TestContext/TestRenderer's Dispose method has been called, which causes the render tree frames to enter into an invalid state. We did have a test in the deterministic render branch related to disposing components that were causing issues too, as far as I remember, so there may be a fix in this branch that fixes that. |
Fair point - I did have the same picture where I removed all What for sure changed is how we implemented EDIT: Hopefully :D |
|
I do want to wait a bit and give the blazor team a chance to respond to my question. It may confirm my assumptions or force us to look for other solutions/causes. |
c93e1c8 to
9c5e872
Compare
b342aa2 to
02f5909
Compare
…ponents blocking concurrent render tree updates
02f5909 to
db411c3
Compare
|
With Steve's feedback in mind, I still think this is a decent solution. Give it a look over again and let me know what your thoughts are. |
The second round of changes that should prevent stack overflow reported in #1064.
I will attempt to push a preview release directly from this branch so we can test it before going further.
PR meta checklist
mainbranch for codeor targeted at
stablebranch for documentation that is live on bunit.dev.Code PR specific checklist