Skip to content

Commit

Permalink
fix: prevent endless recursion loading render tree frames (#1132)
Browse files Browse the repository at this point in the history
  • Loading branch information
egil authored Jun 28, 2023
1 parent 4990e75 commit 4e439e9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/bunit.core/Rendering/TestRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ private void UpdateDisplay(in RenderBatch renderBatch)
{
var id = renderBatch.DisposedComponentIDs.Array[i];

// Add disposed components to the frames collection
// to avoid them being added into the dictionary later during a
// LoadRenderTreeFrames/GetOrLoadRenderTreeFrame call.
renderEvent.Frames.Add(id, default);

logger.LogComponentDisposed(id);

if (renderedComponents.TryGetValue(id, out var rc))
Expand Down Expand Up @@ -443,7 +448,8 @@ private void LoadRenderTreeFrames(int componentId, RenderTreeFrameDictionary fra
for (var i = 0; i < frames.Count; i++)
{
ref var frame = ref frames.Array[i];
if (frame.FrameType == RenderTreeFrameType.Component)

if (frame.FrameType == RenderTreeFrameType.Component && !framesCollection.Contains(frame.ComponentId))
{
LoadRenderTreeFrames(frame.ComponentId, framesCollection);
}
Expand Down

0 comments on commit 4e439e9

Please sign in to comment.