Skip to content

Commit 2a65829

Browse files
Revert "[flutter_tools] Dump backtrace on ios app startup timeout (#101610)" (#101761)
This reverts commit 2978b59.
1 parent 2978b59 commit 2a65829

File tree

4 files changed

+30
-153
lines changed

4 files changed

+30
-153
lines changed

packages/flutter_tools/lib/src/ios/devices.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ class IOSDevice extends Device {
434434
_logger.printTrace('Application launched on the device. Waiting for observatory url.');
435435
final Timer timer = Timer(discoveryTimeout ?? const Duration(seconds: 30), () {
436436
_logger.printError('iOS Observatory not discovered after 30 seconds. This is taking much longer than expected...');
437-
iosDeployDebugger?.pauseDumpBacktraceResume();
438437
});
439438
final Uri? localUri = await observatoryDiscovery?.uri;
440439
timer.cancel();

packages/flutter_tools/lib/src/ios/ios_deploy.dart

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -296,23 +296,12 @@ class IOSDeployDebugger {
296296
// (lldb) Process 6152 detached
297297
static final RegExp _lldbProcessDetached = RegExp(r'Process \d* detached');
298298

299-
// (lldb) Process 6152 resuming
300-
static final RegExp _lldbProcessResuming = RegExp(r'Process \d+ resuming');
301-
302299
// Send signal to stop (pause) the app. Used before a backtrace dump.
303300
static const String _signalStop = 'process signal SIGSTOP';
304301

305-
static const String _processResume = 'process continue';
306-
static const String _processInterrupt = 'process interrupt';
307-
308302
// Print backtrace for all threads while app is stopped.
309303
static const String _backTraceAll = 'thread backtrace all';
310304

311-
/// If this is non-null, then the app process is paused and awaiting backtrace logging.
312-
///
313-
/// The future should be completed once the backtraces are logged.
314-
Completer<void>? _processResumeCompleter;
315-
316305
/// Launch the app on the device, and attach the debugger.
317306
///
318307
/// Returns whether or not the debugger successfully attached.
@@ -330,6 +319,7 @@ class IOSDeployDebugger {
330319
.transform<String>(const LineSplitter())
331320
.listen((String line) {
332321
_monitorIOSDeployFailure(line, _logger);
322+
333323
// (lldb) run
334324
// success
335325
// 2020-09-15 13:42:25.185474-0700 Runner[477:181141] flutter: The Dart VM service is listening on http://127.0.0.1:57782/
@@ -360,26 +350,16 @@ class IOSDeployDebugger {
360350
// Even though we're not "detached", just stopped, mark as detached so the backtrace
361351
// is only show in verbose.
362352
_debuggerState = _IOSDeployDebuggerState.detached;
363-
364-
// If we paused the app and are waiting to resume it, complete the completer
365-
final Completer<void>? processResumeCompleter = _processResumeCompleter;
366-
if (processResumeCompleter != null) {
367-
_processResumeCompleter = null;
368-
processResumeCompleter.complete();
369-
}
370353
return;
371354
}
372355

373356
if (line.contains('PROCESS_STOPPED') || _lldbProcessStopped.hasMatch(line)) {
374357
// The app has been stopped. Dump the backtrace, and detach.
375358
_logger.printTrace(line);
376359
_iosDeployProcess?.stdin.writeln(_backTraceAll);
377-
if (_processResumeCompleter == null) {
378-
detach();
379-
}
360+
detach();
380361
return;
381362
}
382-
383363
if (line.contains('PROCESS_EXITED') || _lldbProcessExit.hasMatch(line)) {
384364
// The app exited or crashed, so exit. Continue passing debugging
385365
// messages to the log reader until it exits to capture crash dumps.
@@ -394,13 +374,6 @@ class IOSDeployDebugger {
394374
return;
395375
}
396376

397-
if (_lldbProcessResuming.hasMatch(line)) {
398-
_logger.printTrace(line);
399-
// we marked this detached when we received [_backTraceAll]
400-
_debuggerState = _IOSDeployDebuggerState.attached;
401-
return;
402-
}
403-
404377
if (_debuggerState != _IOSDeployDebuggerState.attached) {
405378
_logger.printTrace(line);
406379
return;
@@ -460,28 +433,11 @@ class IOSDeployDebugger {
460433
return success;
461434
}
462435

463-
/// Pause app, dump backtrace for debugging, and resume.
464-
Future<void> pauseDumpBacktraceResume() async {
465-
if (!debuggerAttached) {
466-
return;
467-
}
468-
final Completer<void> completer = Completer<void>();
469-
_processResumeCompleter = completer;
470-
try {
471-
// Stop the app, which will prompt the backtrace to be printed for all threads in the stdoutSubscription handler.
472-
_iosDeployProcess?.stdin.writeln(_processInterrupt);
473-
} on SocketException catch (error) {
474-
_logger.printTrace('Could not stop app from debugger: $error');
475-
}
476-
// wait for backtrace to be dumped
477-
await completer.future;
478-
_iosDeployProcess?.stdin.writeln(_processResume);
479-
}
480-
481436
Future<void> stopAndDumpBacktrace() async {
482437
if (!debuggerAttached) {
483438
return;
484439
}
440+
485441
try {
486442
// Stop the app, which will prompt the backtrace to be printed for all threads in the stdoutSubscription handler.
487443
_iosDeployProcess?.stdin.writeln(_signalStop);

packages/flutter_tools/test/general.shard/ios/ios_deploy_test.dart

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -330,71 +330,6 @@ void main () {
330330
'process detach',
331331
]);
332332
});
333-
334-
testWithoutContext('pause with backtrace', () async {
335-
final StreamController<List<int>> stdin = StreamController<List<int>>();
336-
final Stream<String> stdinStream = stdin.stream.transform<String>(const Utf8Decoder());
337-
const String stdout = '''
338-
(lldb) run
339-
success
340-
Log on attach
341-
(lldb) Process 6156 stopped
342-
* thread #1, stop reason = Assertion failed:
343-
thread backtrace all
344-
process continue
345-
* thread #1, stop reason = signal SIGSTOP
346-
* frame #0: 0x0000000102eaee80 dyld`dyld3::MachOFile::read_uleb128(Diagnostics&, unsigned char const*&, unsigned char const*) + 36
347-
frame #1: 0x0000000102eabbd4 dyld`dyld3::MachOLoaded::trieWalk(Diagnostics&, unsigned char const*, unsigned char const*, char const*) + 332
348-
frame #2: 0x0000000102eaa078 dyld`DyldSharedCache::hasImagePath(char const*, unsigned int&) const + 144
349-
frame #3: 0x0000000102eaa13c dyld`DyldSharedCache::hasNonOverridablePath(char const*) const + 44
350-
frame #4: 0x0000000102ebc404 dyld`dyld3::closure::ClosureBuilder::findImage(char const*, dyld3::closure::ClosureBuilder::LoadedImageChain const&, dyld3::closure::ClosureBuilder::BuilderLoadedImage*&, dyld3::closure::ClosureBuilder::LinkageType, unsigned int, bool) +
351-
352-
frame #5: 0x0000000102ebd974 dyld`invocation function for block in dyld3::closure::ClosureBuilder::recursiveLoadDependents(dyld3::closure::ClosureBuilder::LoadedImageChain&, bool) + 136
353-
frame #6: 0x0000000102eae1b0 dyld`invocation function for block in dyld3::MachOFile::forEachDependentDylib(void (char const*, bool, bool, bool, unsigned int, unsigned int, bool&) block_pointer) const + 136
354-
frame #7: 0x0000000102eadc38 dyld`dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 168
355-
frame #8: 0x0000000102eae108 dyld`dyld3::MachOFile::forEachDependentDylib(void (char const*, bool, bool, bool, unsigned int, unsigned int, bool&) block_pointer) const + 116
356-
frame #9: 0x0000000102ebd80c dyld`dyld3::closure::ClosureBuilder::recursiveLoadDependents(dyld3::closure::ClosureBuilder::LoadedImageChain&, bool) + 164
357-
frame #10: 0x0000000102ebd8a8 dyld`dyld3::closure::ClosureBuilder::recursiveLoadDependents(dyld3::closure::ClosureBuilder::LoadedImageChain&, bool) + 320
358-
frame #11: 0x0000000102ebd8a8 dyld`dyld3::closure::ClosureBuilder::recursiveLoadDependents(dyld3::closure::ClosureBuilder::LoadedImageChain&, bool) + 320
359-
frame #12: 0x0000000102ebd8a8 dyld`dyld3::closure::ClosureBuilder::recursiveLoadDependents(dyld3::closure::ClosureBuilder::LoadedImageChain&, bool) + 320
360-
frame #13: 0x0000000102ebd8a8 dyld`dyld3::closure::ClosureBuilder::recursiveLoadDependents(dyld3::closure::ClosureBuilder::LoadedImageChain&, bool) + 320
361-
frame #14: 0x0000000102ebd8a8 dyld`dyld3::closure::ClosureBuilder::recursiveLoadDependents(dyld3::closure::ClosureBuilder::LoadedImageChain&, bool) + 320
362-
frame #15: 0x0000000102ebd8a8 dyld`dyld3::closure::ClosureBuilder::recursiveLoadDependents(dyld3::closure::ClosureBuilder::LoadedImageChain&, bool) + 320
363-
frame #16: 0x0000000102ec7638 dyld`dyld3::closure::ClosureBuilder::makeLaunchClosure(dyld3::closure::LoadedFileInfo const&, bool) + 752
364-
frame #17: 0x0000000102e8fcf0 dyld`dyld::buildLaunchClosure(unsigned char const*, dyld3::closure::LoadedFileInfo const&, char const**) + 344
365-
frame #18: 0x0000000102e8e938 dyld`dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 2876
366-
frame #19: 0x0000000102e8922c dyld`dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) + 432
367-
frame #20: 0x0000000102e89038 dyld`_dyld_start + 56
368-
''';
369-
final BufferLogger logger = BufferLogger.test();
370-
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
371-
FakeCommand(
372-
command: const <String>[
373-
'ios-deploy',
374-
],
375-
stdout: stdout,
376-
stdin: IOSink(stdin.sink),
377-
),
378-
]);
379-
final IOSDeployDebugger iosDeployDebugger = IOSDeployDebugger.test(
380-
processManager: processManager,
381-
logger: logger,
382-
);
383-
await iosDeployDebugger.launchAndAttach();
384-
await iosDeployDebugger.pauseDumpBacktraceResume();
385-
// verify stacktrace was logged to trace
386-
expect(
387-
logger.traceText,
388-
contains(
389-
'frame #0: 0x0000000102eaee80 dyld`dyld3::MachOFile::read_uleb128(Diagnostics&, unsigned char const*&, unsigned char const*) + 36',
390-
),
391-
);
392-
expect(await stdinStream.take(3).toList(), <String>[
393-
'thread backtrace all',
394-
'\n',
395-
'process detach',
396-
]);
397-
});
398333
});
399334

400335
group('IOSDeploy.uninstallApp', () {

packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
// @dart = 2.8
66

77
import 'dart:async';
8-
import 'dart:convert';
98

109
import 'package:file/memory.dart';
1110
import 'package:flutter_tools/src/artifacts.dart';
1211
import 'package:flutter_tools/src/base/file_system.dart';
13-
import 'package:flutter_tools/src/base/io.dart';
1412
import 'package:flutter_tools/src/base/logger.dart';
1513
import 'package:flutter_tools/src/base/platform.dart';
1614
import 'package:flutter_tools/src/build_info.dart';
@@ -66,35 +64,26 @@ const FakeCommand kLaunchDebugCommand = FakeCommand(command: <String>[
6664
});
6765

6866
// The command used to actually launch the app and attach the debugger with args in debug.
69-
FakeCommand attachDebuggerCommand({
70-
IOSink stdin,
71-
Completer<void>/*?*/ completer,
72-
}) {
73-
return FakeCommand(
74-
command: const <String>[
75-
'script',
76-
'-t',
77-
'0',
78-
'/dev/null',
79-
'HostArtifact.iosDeploy',
80-
'--id',
81-
'123',
82-
'--bundle',
83-
'/',
84-
'--debug',
85-
'--no-wifi',
86-
'--args',
87-
'--enable-dart-profiling --disable-service-auth-codes --enable-checked-mode --verify-entry-points',
88-
],
89-
completer: completer,
90-
environment: const <String, String>{
91-
'PATH': '/usr/bin:null',
92-
'DYLD_LIBRARY_PATH': '/path/to/libraries',
93-
},
94-
stdout: '(lldb) run\nsuccess',
95-
stdin: stdin,
96-
);
97-
}
67+
const FakeCommand kAttachDebuggerCommand = FakeCommand(command: <String>[
68+
'script',
69+
'-t',
70+
'0',
71+
'/dev/null',
72+
'HostArtifact.iosDeploy',
73+
'--id',
74+
'123',
75+
'--bundle',
76+
'/',
77+
'--debug',
78+
'--no-wifi',
79+
'--args',
80+
'--enable-dart-profiling --disable-service-auth-codes --enable-checked-mode --verify-entry-points'
81+
], environment: <String, String>{
82+
'PATH': '/usr/bin:null',
83+
'DYLD_LIBRARY_PATH': '/path/to/libraries',
84+
},
85+
stdout: '(lldb) run\nsuccess',
86+
);
9887

9988
void main() {
10089
testWithoutContext('disposing device disposes the portForwarder and logReader', () async {
@@ -119,7 +108,7 @@ void main() {
119108
testWithoutContext('IOSDevice.startApp attaches in debug mode via log reading on iOS 13+', () async {
120109
final FileSystem fileSystem = MemoryFileSystem.test();
121110
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
122-
attachDebuggerCommand(),
111+
kAttachDebuggerCommand,
123112
]);
124113
final IOSDevice device = setUpIOSDevice(
125114
processManager: processManager,
@@ -194,10 +183,8 @@ void main() {
194183
testWithoutContext('IOSDevice.startApp prints warning message if discovery takes longer than configured timeout', () async {
195184
final FileSystem fileSystem = MemoryFileSystem.test();
196185
final BufferLogger logger = BufferLogger.test();
197-
final CompleterIOSink stdin = CompleterIOSink();
198-
final Completer<void> completer = Completer<void>();
199186
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
200-
attachDebuggerCommand(stdin: stdin, completer: completer),
187+
kAttachDebuggerCommand,
201188
]);
202189
final IOSDevice device = setUpIOSDevice(
203190
processManager: processManager,
@@ -216,8 +203,11 @@ void main() {
216203
device.setLogReader(iosApp, deviceLogReader);
217204

218205
// Start writing messages to the log reader.
219-
deviceLogReader.addLine('Foo');
220-
deviceLogReader.addLine('The Dart VM service is listening on http://127.0.0.1:456');
206+
Timer.run(() async {
207+
await Future<void>.delayed(const Duration(milliseconds: 1));
208+
deviceLogReader.addLine('Foo');
209+
deviceLogReader.addLine('The Dart VM service is listening on http://127.0.0.1:456');
210+
});
221211

222212
final LaunchResult launchResult = await device.startApp(iosApp,
223213
prebuiltApplication: true,
@@ -230,9 +220,6 @@ void main() {
230220
expect(launchResult.hasObservatory, true);
231221
expect(await device.stopApp(iosApp), false);
232222
expect(logger.errorText, contains('iOS Observatory not discovered after 30 seconds. This is taking much longer than expected...'));
233-
expect(utf8.decoder.convert(stdin.writes.first), contains('process interrupt'));
234-
completer.complete();
235-
expect(processManager, hasNoRemainingExpectations);
236223
});
237224

238225
testWithoutContext('IOSDevice.startApp succeeds in release mode', () async {

0 commit comments

Comments
 (0)