Skip to content

Prevent GC of value during async eval#9885

Open
srawlins wants to merge 2 commits into
flutter:masterfrom
srawlins:eval-gc
Open

Prevent GC of value during async eval#9885
srawlins wants to merge 2 commits into
flutter:masterfrom
srawlins:eval-gc

Conversation

@srawlins

@srawlins srawlins commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Gemini suggests this to reduce flakiness in integration tests, some of which strongly rely on eval. Gemini looked at recent failed integration tests to suggest this.

@srawlins srawlins requested a review from kenzieschmoll as a code owner July 9, 2026 21:10

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request fixes garbage collection issues with the result list in asyncEval on both native VM and web by keeping a strong reference to the reader object in the target app until the future resolves. The reviewer pointed out that using Timer.periodic inside the evaluated expression might fail if the target library does not explicitly import dart:async. They suggested using an asynchronous loop with Future.delayed instead, as Future is part of dart:core and guaranteed to be available in any Dart library context.

Comment thread packages/devtools_app_shared/lib/src/service/eval_on_dart_library.dart Outdated
Comment thread packages/devtools_app_shared/lib/src/service/eval_on_dart_library.dart Outdated
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.

2 participants