Skip to content

fix(flame_devtools): Fix component tree growing list and stale snapshot#3911

Open
Barba2k2 wants to merge 2 commits intoflame-engine:mainfrom
Barba2k2:fix/devtools-extension-3289
Open

fix(flame_devtools): Fix component tree growing list and stale snapshot#3911
Barba2k2 wants to merge 2 commits intoflame-engine:mainfrom
Barba2k2:fix/devtools-extension-3289

Conversation

@Barba2k2
Copy link
Copy Markdown

@Barba2k2 Barba2k2 commented May 2, 2026

Description

Two unrelated UI bugs in the DevTools extension surfaced by #3289 (running the extension against a game with constant animations).

1. Component tree never fills the panel

ComponentTreeSection wrapped TreeView.simple(shrinkWrap: true) inside a SingleChildScrollView. With shrinkWrap: true the tree sized itself to its content and let the outer scroll view be unbounded; it therefore grew on every animation frame and never filled the Expanded slot above it — that's the "constantly growing list that does not take up the entire vertical space" in the report.

Dropped the outer SingleChildScrollView and the shrinkWrap: true flag. TreeView.simple now owns its scrolling and fills the available height the parent gives it.

2. Selected-component snapshot is stale ("gray image")

Base64Image fed snapshot bytes through Flame.images.fromBase64(imageId, base64), keyed by component id only. Re-requesting a snapshot for the same component after its game state changed hit the global cache and got the previous decoded frame back — that's the gray/stale image in the report.

Converted Base64Image to a StatefulWidget that decodes the base64 directly via decodeImageFromList, owns the resulting ui.Image, and disposes it on widget removal or when base64 / imageId changes. Bypasses the global cache entirely, which is the right call for these short-lived debug snapshots.

How to verify

  1. melos devtools-build
  2. Run examples/ and open the Rogue Shooter game.
  3. Open DevTools → Flame tab.
  4. The component tree should fill the left panel and scroll internally instead of growing each frame.
  5. Selecting a component repeatedly (or letting time pass) should show a fresh snapshot rather than the first cached frame.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • [-] I have updated/added tests for ALL new/updated/fixed functionality. (flame_devtools has no test suite; manual verification steps above)
  • [-] I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • [-] I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Fixes #3289

Two unrelated UI bugs in the DevTools extension surfaced by issue flame-engine#3289
when running against games with constant animations:

1. The component tree was wrapped in a SingleChildScrollView with
   shrinkWrap: true on the inner TreeView. The tree therefore sized
   itself to its content and grew on every frame, never filling the
   Expanded slot above it. Drop the redundant outer scroll view and
   let TreeView own its scrolling and use the available height.

2. Base64Image fed the snapshot bytes through Flame.images.fromBase64
   keyed by component id, so re-selecting the same component (or
   re-requesting a snapshot for it after the game state changed) hit
   the global cache and rendered a stale frame — the gray image
   reported in the issue. Decode the bytes directly inside the widget
   and dispose the ui.Image when the data or widget changes.

Fixes flame-engine#3289
@luanpotter luanpotter requested a review from erickzanardo May 2, 2026 15:44
Copy link
Copy Markdown
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description needs to follow the PR template.

@Barba2k2
Copy link
Copy Markdown
Author

Barba2k2 commented May 3, 2026

@spydon updated the description to follow the PR template — thanks for the heads up.

@Barba2k2 Barba2k2 requested a review from spydon May 3, 2026 14:01
Copy link
Copy Markdown
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DevTools extension is buggy with constant animations

2 participants