[Memory Panel] Fix canvasChartWidth has not been initialized error when changing the zoom duration#9573
Merged
elliette merged 2 commits intoflutter:masterfrom Dec 15, 2025
Merged
Conversation
srawlins
approved these changes
Dec 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8187
Fixes the "
canvasChartWidthhas not been initialized" error which can occur when setting the zoom duration in the Memory Panel.Explanation
Setting the
zoomDurationfor a chart triggers a call tocanvasChartWidth, which is only set after a chart has been painted:In
paint():devtools/packages/devtools_app/lib/src/shared/charts/chart.dart
Lines 158 to 161 in 2f73978
In
computeChartArea():devtools/packages/devtools_app/lib/src/shared/charts/chart_controller.dart
Lines 409 to 411 in 2f73978
However, not all charts are painted by default. The Android chart is only conditionally painted:
devtools/packages/devtools_app/lib/src/screens/memory/panes/chart/widgets/chart_pane.dart
Lines 166 to 170 in 2f73978
Therefore, the fix here is to only set the
zoomDurationfor the Android chart if it's visible.