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
[iOS] Dispose of log readers and port forwarders if launch fails #127140
Conversation
return LaunchResult.failed(); | ||
} | ||
return LaunchResult.succeeded(vmServiceUri: localUri); | ||
} on ProcessException catch (e) { | ||
await iosDeployDebugger?.stopAndDumpBacktrace(); | ||
_logger.printError(e.message); | ||
await dispose(); | ||
return LaunchResult.failed(); | ||
} finally { |
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.
any reason not to just call dispose()
from the finally
block?
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.
We don't want it to dispose when it launches successfully
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.
ahh yeah, good point :)
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ | ||
FakeCommand( | ||
command: const <String>['ios-deploy'], | ||
stdout: '(lldb) run\r\nsuccess\r\nsuccess\r\nprocess signal SIGSTOP\r\n\r\nerror: Failed to send signal 17: failed to send signal 17', |
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.
Out of curiosity, would we actually expect to see '\r'
here?
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.
Oh good question, I'm not sure. I just grabbed that from the test above. I'll try and figure out
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.
not worth investigating, just wondering if there was a legit reason.
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 just happened to come across the answer to this:
flutter/packages/flutter_tools/lib/src/ios/ios_deploy.dart
Lines 477 to 480 in 4f6f188
// The lldb console stream from ios-deploy is separated lines by an extra \r\n. | |
// To avoid all lines being double spaced, if the last line from the | |
// debugger was not an empty line, skip this empty line. | |
// This will still cause "legit" logged newlines to be doubled... |
@@ -147,6 +147,33 @@ void main () { | |||
expect(logger.traceText, contains('* thread #1')); | |||
}); | |||
|
|||
testWithoutContext('debugger attached and stop failed', () async { |
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.
Is this test verifying any of your changes here? It's passing for me if I revert your other changes.
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.
Oops, let me rework it
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.
Okay updated it
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.
Nice! Thanks for this fix!
flutter/flutter@077d644...ab57304 2023-05-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 482c99af9c69 to aac09195688d (1 revision) (flutter/flutter#127241) 2023-05-20 andrewrkolos@gmail.com Reland "[tool] Move Java functions to their own file" (flutter/flutter#126577) 2023-05-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from f0c02aee69db to 482c99af9c69 (1 revision) (flutter/flutter#127240) 2023-05-19 82336674+gilnobrega@users.noreply.github.com Do not animate `TabBarView` if controller is invalid (flutter/flutter#123442) 2023-05-19 54558023+keyonghan@users.noreply.github.com Run Mac intel only targets on both intel and arm (flutter/flutter#127230) 2023-05-19 737941+loic-sharma@users.noreply.github.com [Windows] Ensure window is shown (flutter/flutter#127046) 2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3267fa29491a to f0c02aee69db (4 revisions) (flutter/flutter#127233) 2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 2b14f8a1f21c to 3267fa29491a (4 revisions) (flutter/flutter#127224) 2023-05-19 pq@users.noreply.github.com fixes to anticipate next Dart linter release (flutter/flutter#127211) 2023-05-19 katelovett@google.com Remove deprecated OverscrollIndicatorNotification.disallowGlow (flutter/flutter#127050) 2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from f471b37a2146 to 2b14f8a1f21c (1 revision) (flutter/flutter#127221) 2023-05-19 christopherfujino@gmail.com [flutter_tools] only try to take a screenshot from flutter drive if the --screenshot flag is passed (flutter/flutter#127150) 2023-05-19 zanderso@users.noreply.github.com Roll goldctl to f808dcff91b221ae313e540c09d79696cd08b8de (flutter/flutter#127218) 2023-05-19 engine-flutter-autoroll@skia.org Roll Packages from b31a128 to 1e214d7 (3 revisions) (flutter/flutter#127217) 2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from a0ea4d2d9ea5 to f471b37a2146 (1 revision) (flutter/flutter#127212) 2023-05-19 joshualitt@google.com Revert "Migrate benchmarks to package:web" (flutter/flutter#127207) 2023-05-19 ychris@google.com [tool] delete xcresult bundle file before each xcode retry. (flutter/flutter#127144) 2023-05-19 vashworth@google.com [iOS] Dispose of log readers and port forwarders if launch fails (flutter/flutter#127140) 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 dit@google.com,rmistry@google.com,stuartmorgan@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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…tter#127140) When tests run in our CI using `flutter drive`, if there is a failure it will loop and try again. https://github.com/flutter/flutter/blob/434b81f1a58b8528299a63ae7c3ded2aa519e3c9/packages/flutter_tools/lib/src/drive/drive_service.dart#L177-L186 However, it's using the same `device` instance for each iteration. So what was happening was when it would fail to launch, it would tell its listeners that it was cancelled. https://github.com/flutter/flutter/blob/434b81f1a58b8528299a63ae7c3ded2aa519e3c9/packages/flutter_tools/lib/src/ios/ios_deploy.dart#L486-L489 Then when the next iteration started, the `vmServiceDiscovery` would immediately return with null because the `deviceLogReader` would be cached from the previous iteration and would already be cancelled. Therefore, bypassing and cancelling the timer. https://github.com/flutter/flutter/blob/434b81f1a58b8528299a63ae7c3ded2aa519e3c9/packages/flutter_tools/lib/src/ios/devices.dart#L585-L591 https://github.com/flutter/flutter/blob/434b81f1a58b8528299a63ae7c3ded2aa519e3c9/packages/flutter_tools/lib/src/ios/devices.dart#L627 In addition, it seems like sometimes the stop would fail and therefore the the drain would never get the signal that it was done and therefore would hang forever. There was no indication that the stop had failed though because the logs were going to the stream that had no listeners since `deviceLogReader` was already cancelled. https://github.com/flutter/flutter/blob/434b81f1a58b8528299a63ae7c3ded2aa519e3c9/packages/flutter_tools/lib/src/ios/ios_deploy.dart#L563-L576 Fixes flutter#127141
…r#4051) flutter/flutter@077d644...ab57304 2023-05-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 482c99af9c69 to aac09195688d (1 revision) (flutter/flutter#127241) 2023-05-20 andrewrkolos@gmail.com Reland "[tool] Move Java functions to their own file" (flutter/flutter#126577) 2023-05-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from f0c02aee69db to 482c99af9c69 (1 revision) (flutter/flutter#127240) 2023-05-19 82336674+gilnobrega@users.noreply.github.com Do not animate `TabBarView` if controller is invalid (flutter/flutter#123442) 2023-05-19 54558023+keyonghan@users.noreply.github.com Run Mac intel only targets on both intel and arm (flutter/flutter#127230) 2023-05-19 737941+loic-sharma@users.noreply.github.com [Windows] Ensure window is shown (flutter/flutter#127046) 2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3267fa29491a to f0c02aee69db (4 revisions) (flutter/flutter#127233) 2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 2b14f8a1f21c to 3267fa29491a (4 revisions) (flutter/flutter#127224) 2023-05-19 pq@users.noreply.github.com fixes to anticipate next Dart linter release (flutter/flutter#127211) 2023-05-19 katelovett@google.com Remove deprecated OverscrollIndicatorNotification.disallowGlow (flutter/flutter#127050) 2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from f471b37a2146 to 2b14f8a1f21c (1 revision) (flutter/flutter#127221) 2023-05-19 christopherfujino@gmail.com [flutter_tools] only try to take a screenshot from flutter drive if the --screenshot flag is passed (flutter/flutter#127150) 2023-05-19 zanderso@users.noreply.github.com Roll goldctl to f808dcff91b221ae313e540c09d79696cd08b8de (flutter/flutter#127218) 2023-05-19 engine-flutter-autoroll@skia.org Roll Packages from b31a128 to 1e214d7 (3 revisions) (flutter/flutter#127217) 2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from a0ea4d2d9ea5 to f471b37a2146 (1 revision) (flutter/flutter#127212) 2023-05-19 joshualitt@google.com Revert "Migrate benchmarks to package:web" (flutter/flutter#127207) 2023-05-19 ychris@google.com [tool] delete xcresult bundle file before each xcode retry. (flutter/flutter#127144) 2023-05-19 vashworth@google.com [iOS] Dispose of log readers and port forwarders if launch fails (flutter/flutter#127140) 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 dit@google.com,rmistry@google.com,stuartmorgan@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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
When tests run in our CI using
flutter drive
, if there is a failure it will loop and try again.flutter/packages/flutter_tools/lib/src/drive/drive_service.dart
Lines 177 to 186 in 434b81f
However, it's using the same
device
instance for each iteration. So what was happening was when it would fail to launch, it would tell its listeners that it was cancelled.flutter/packages/flutter_tools/lib/src/ios/ios_deploy.dart
Lines 486 to 489 in 434b81f
Then when the next iteration started, the
vmServiceDiscovery
would immediately return with null because thedeviceLogReader
would be cached from the previous iteration and would already be cancelled. Therefore, bypassing and cancelling the timer.flutter/packages/flutter_tools/lib/src/ios/devices.dart
Lines 585 to 591 in 434b81f
flutter/packages/flutter_tools/lib/src/ios/devices.dart
Line 627 in 434b81f
In addition, it seems like sometimes the stop would fail and therefore the the drain would never get the signal that it was done and therefore would hang forever. There was no indication that the stop had failed though because the logs were going to the stream that had no listeners since
deviceLogReader
was already cancelled.flutter/packages/flutter_tools/lib/src/ios/ios_deploy.dart
Lines 563 to 576 in 434b81f
Fixes #127141
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.