-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[tool] Guard process writes to frontend server in ResidentCompiler
#152358
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
[tool] Guard process writes to frontend server in ResidentCompiler
#152358
Conversation
f82a07e
to
7e24822
Compare
a5d97f0
to
e4adba7
Compare
// TODO(andrewkolos): Concurrent calls to ProcessUtils.writelnToStdinUnsafe | ||
// against the same stdin will result in an exception. To guard against this, | ||
// we need to force calls to run serially. Ideally, this wouldn't be | ||
// necessary since we shouldn't have multiple concurrent writes to the | ||
// compiler process. However, we do (https://github.com/flutter/flutter/issues/152577). |
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.
I'm okay with not shaving this yak now, because 1) event loop turns and stdin flushes are pretty fast, so the risk of it changing any existing races probably isn't high and 2) this is (potentially) blocking us getting stack traces on the top crasher of the flutter tool, which I want to resolve ASAP.
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.
Side note: maybe instead of managing a pool and having ProcessUtils.writelnToStdinUnsafe
and friends, we should create an abstraction (say, ProcessStdinWriter
) that manages this stuff for us. While we are at it, maybe we should just replace Process
from dart:io
with our own wrapper entirely 🙃.
This is needed because the caller might call testTimeRecorder.print before this method got a chance to call testTimeRecorder.stop
ee0acd1
to
e5273a8
Compare
final PoolResource request = await _serverStdinWritePool.request(); | ||
try { | ||
for (final String line in lines) { | ||
await ProcessUtils.writelnToStdinUnsafe(stdin: server.stdin, line: line); |
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.
i worry that we're adding a lot of flush calls and asynchronous suspensions here. Would it work if we do:
await ProcessUtils.writelnToStdinUnsafe(stdin: server.stdin, line: lines.join('\n'));
Effectively batching the writelns before a single flush call?
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.
Hmm, a hot reload test timed out:
24:00 +58 -1: test/integration.shard/hot_reload_test.dart: hot restart works without error [E]
TimeoutException after 0:15:00.000000: Test timed out after 15 minutes.
dart:isolate _RawReceivePort._handleMessage
Did the batching break the compiler?
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.
This may be a manifestation of #152220 (or something with the same root cause), but now that you point it out...let me see if there's anything in the logs that can support this.
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.
I think this is different. I find this from the logs interesting:
<=stdout= [{"event":"app.stop","params":{"appId":"0b7edf75-f1fe-442c-ad22-155775e36df2"}}]
Exception: Received app.stop event while waiting for response to request 1
for reference:
Performing hot restart...
=stdin=> [{"id":1,"method":"app.restart","params":{"appId":"0b7edf75-f1fe-442c-ad22-155775e36df2","fullRestart":true,"pause":false,"debounce":false,"debounceDurationOverrideMs":null}}]
So the tool never gets a response from the VM service for the app.restart
call? Unfortunately it looks like the last message from the VM service is truncated in the logs.
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.
LGTM
Failed to create CP due to merge conflicts. |
Manual roll requested by tarrinneal@google.com flutter/flutter@1dd7141...0a7f8af 2024-08-06 rmolivares@renzo-olivares.dev Support clearing selection programmatically through SelectableRegionState (flutter/flutter#152882) 2024-08-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from aabd582e9c7e to 206e86ee8a40 (4 revisions) (flutter/flutter#152962) 2024-08-06 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 4.3.4 to 4.3.6 (flutter/flutter#152964) 2024-08-06 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.15 to 3.26.0 (flutter/flutter#152965) 2024-08-06 andrewrkolos@gmail.com [tool] Guard process writes to frontend server in `ResidentCompiler` (flutter/flutter#152358) 2024-08-06 zanderso@users.noreply.github.com Fix Linux_android_emu tests late initialization errors (flutter/flutter#152932) 2024-08-06 fluttergithubbot@gmail.com Marks Mac integration_ui_test_test_macos to be flaky (flutter/flutter#152213) 2024-08-06 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#152956) 2024-08-06 pateltirth454@gmail.com [API Examples] `scroll_direction.0_test.dart` & `growth_direction.0_test.dart` (flutter/flutter#152941) 2024-08-06 jonahwilliams@google.com [devicelab] opt gallery benchmarks and platform view test into merged thread mode. (flutter/flutter#152940) 2024-08-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from e97955bf12ac to aabd582e9c7e (1 revision) (flutter/flutter#152948) 2024-08-06 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#152945) 2024-08-06 59215665+davidhicks980@users.noreply.github.com [material/menu_anchor.dart] MenuAnchor focus refactoring for RawMenuAnchor (flutter/flutter#150950) 2024-08-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 99da2cab3f6d to e97955bf12ac (2 revisions) (flutter/flutter#152944) 2024-08-06 gazal.gafoor.k@gmail.com fix: add parameter to maintainState of SearchDelegate (flutter/flutter#152444) 2024-08-06 34465683+rkishan516@users.noreply.github.com Feat: Add fillColor property for cupertinoCheckbox (flutter/flutter#151761) 2024-08-06 42016383+DBowen33@users.noreply.github.com Slider does not show changed label value for keyboard users fix (flutter/flutter#152886) 2024-08-06 nate.w5687@gmail.com Add Nate Wilson to authors (flutter/flutter#152907) 2024-08-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 7fc38bef4775 to 99da2cab3f6d (1 revision) (flutter/flutter#152934) 2024-08-06 engine-flutter-autoroll@skia.org Roll Packages from 82e8d1e to 551bde5 (12 revisions) (flutter/flutter#152930) 2024-08-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 84116159ebfc to 7fc38bef4775 (1 revision) (flutter/flutter#152924) 2024-08-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from f75ffb65cfe3 to 84116159ebfc (1 revision) (flutter/flutter#152917) 2024-08-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from f5f6e966e7e7 to f75ffb65cfe3 (2 revisions) (flutter/flutter#152915) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC rmistry@google.com,stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
// TODO(andrewkolos): This is a hack. Adding any more awaits to the compiler's | ||
// recompile method will cause this to be insufficent. | ||
// https://github.com/flutter/flutter/issues/151255. | ||
await null; |
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.
There is some shady looking stuff going on in this PR. I am skeptical about cp'ing this to stable.
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.
This was an extension of an existing hack (there was already one await null
here); but, yes, I agree there are definitely a few unshaven yaks when it comes to Dart (re)-compilation and/or hot-reloading in the tool.
While not CP'ing this change could delay getting stack traces on #137184 (easily the top crasher in the tool), I certainly understand not wanting to CP this.
P.S. I saw #153026. Yes, hot reload has been flaky for a while. I'm doing some archeology to put a summary together here. However, if hot reload has become especially flaky (well over 2%) since this PR landed, I'm okay with reverting.
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.
I think we should do a speculative revert, yeah. I will add the tag.
Reason for revert: Speculative revert to determine whether this PR is related to #153026 |
…ompiler` (#152358)" (#153028) Reverts: #152358 Initiated by: zanderso Reason for reverting: Speculative revert to determine whether this PR is related to #153026 Original PR Author: andrewkolos Reviewed By: {christopherfujino} This change reverts the following previous change: Contributes to fixing #137184. Cleaned up version of earlier PR, #152187. This PR guards all the writes to `Process::stdin` by wrapping them with `ProcessUtils.writelnToStdinUnsafe`. This way, if any writes fail, we should at least get a stacktrace in our crash reporting.
…lutter#152358) Contributes to fixing flutter#137184. Cleaned up version of earlier PR, flutter#152187. This PR guards all the writes to `Process::stdin` by wrapping them with `ProcessUtils.writelnToStdinUnsafe`. This way, if any writes fail, we should at least get a stacktrace in our crash reporting.
…ompiler` (flutter#152358)" (flutter#153028) Reverts: flutter#152358 Initiated by: zanderso Reason for reverting: Speculative revert to determine whether this PR is related to flutter#153026 Original PR Author: andrewkolos Reviewed By: {christopherfujino} This change reverts the following previous change: Contributes to fixing flutter#137184. Cleaned up version of earlier PR, flutter#152187. This PR guards all the writes to `Process::stdin` by wrapping them with `ProcessUtils.writelnToStdinUnsafe`. This way, if any writes fail, we should at least get a stacktrace in our crash reporting.
…ompiler` (flutter#152358)" (flutter#153028) Reverts: flutter#152358 Initiated by: zanderso Reason for reverting: Speculative revert to determine whether this PR is related to flutter#153026 Original PR Author: andrewkolos Reviewed By: {christopherfujino} This change reverts the following previous change: Contributes to fixing flutter#137184. Cleaned up version of earlier PR, flutter#152187. This PR guards all the writes to `Process::stdin` by wrapping them with `ProcessUtils.writelnToStdinUnsafe`. This way, if any writes fail, we should at least get a stacktrace in our crash reporting.
…lutter#152358) Contributes to fixing flutter#137184. Cleaned up version of earlier PR, flutter#152187. This PR guards all the writes to `Process::stdin` by wrapping them with `ProcessUtils.writelnToStdinUnsafe`. This way, if any writes fail, we should at least get a stacktrace in our crash reporting.
…ompiler` (flutter#152358)" (flutter#153028) Reverts: flutter#152358 Initiated by: zanderso Reason for reverting: Speculative revert to determine whether this PR is related to flutter#153026 Original PR Author: andrewkolos Reviewed By: {christopherfujino} This change reverts the following previous change: Contributes to fixing flutter#137184. Cleaned up version of earlier PR, flutter#152187. This PR guards all the writes to `Process::stdin` by wrapping them with `ProcessUtils.writelnToStdinUnsafe`. This way, if any writes fail, we should at least get a stacktrace in our crash reporting.
Contributes to fixing #137184.
Cleaned up version of earlier PR, #152187.
This PR guards all the writes to
Process::stdin
by wrapping them withProcessUtils.writelnToStdinUnsafe
. This way, if any writes fail, we should at least get a stacktrace in our crash reporting.Pre-launch Checklist
///
).