Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e99a66a4
Unverified
Commit
e99a66a4
authored
Mar 17, 2022
by
Christopher Fujino
Committed by
GitHub
Mar 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] check if stream is open before sending message in ios device (#99947)
parent
2386fd90
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
13 deletions
+68
-13
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+21
-10
ios_deploy.dart
packages/flutter_tools/lib/src/ios/ios_deploy.dart
+7
-3
ios_device_logger_test.dart
..._tools/test/general.shard/ios/ios_device_logger_test.dart
+40
-0
No files found.
packages/flutter_tools/lib/src/ios/devices.dart
View file @
e99a66a4
...
...
@@ -647,14 +647,25 @@ class IOSDeviceLogReader extends DeviceLogReader {
// Logging from the dart code has no prefixing metadata.
final
RegExp
_debuggerLoggingRegex
=
RegExp
(
r'^\S* \S* \S*\[[0-9:]*] (.*)'
);
late
final
StreamController
<
String
>
_linesController
=
StreamController
<
String
>.
broadcast
(
@visibleForTesting
late
final
StreamController
<
String
>
linesController
=
StreamController
<
String
>.
broadcast
(
onListen:
_listenToSysLog
,
onCancel:
dispose
,
);
// Sometimes (race condition?) we try to send a log after the controller has
// been closed. See https://github.com/flutter/flutter/issues/99021 for more
// context.
void
_addToLinesController
(
String
message
)
{
if
(!
linesController
.
isClosed
)
{
linesController
.
add
(
message
);
}
}
final
List
<
StreamSubscription
<
void
>>
_loggingSubscriptions
=
<
StreamSubscription
<
void
>>[];
@override
Stream
<
String
>
get
logLines
=>
_
linesController
.
stream
;
Stream
<
String
>
get
logLines
=>
linesController
.
stream
;
@override
FlutterVmService
?
get
connectedVMService
=>
_connectedVMService
;
...
...
@@ -694,7 +705,7 @@ class IOSDeviceLogReader extends DeviceLogReader {
}
final
String
message
=
processVmServiceMessage
(
event
);
if
(
message
.
isNotEmpty
)
{
_
linesController
.
add
(
message
);
_
addToLinesController
(
message
);
}
}
...
...
@@ -717,9 +728,9 @@ class IOSDeviceLogReader extends DeviceLogReader {
}
// Add the debugger logs to the controller created on initialization.
_loggingSubscriptions
.
add
(
debugger
.
logLines
.
listen
(
(
String
line
)
=>
_
linesController
.
add
(
_debuggerLineHandler
(
line
)),
onError:
_
linesController
.
addError
,
onDone:
_
linesController
.
close
,
(
String
line
)
=>
_
addToLinesController
(
_debuggerLineHandler
(
line
)),
onError:
linesController
.
addError
,
onDone:
linesController
.
close
,
cancelOnError:
true
,
));
}
...
...
@@ -737,8 +748,8 @@ class IOSDeviceLogReader extends DeviceLogReader {
process
.
stdout
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_newSyslogLineHandler
());
process
.
stderr
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_newSyslogLineHandler
());
process
.
exitCode
.
whenComplete
(()
{
if
(
_
linesController
.
hasListener
)
{
_
linesController
.
close
();
if
(
linesController
.
hasListener
)
{
linesController
.
close
();
}
});
assert
(
idevicesyslogProcess
==
null
);
...
...
@@ -761,7 +772,7 @@ class IOSDeviceLogReader extends DeviceLogReader {
return
(
String
line
)
{
if
(
printing
)
{
if
(!
_anyLineRegex
.
hasMatch
(
line
))
{
_
linesController
.
add
(
decodeSyslog
(
line
));
_
addToLinesController
(
decodeSyslog
(
line
));
return
;
}
...
...
@@ -773,7 +784,7 @@ class IOSDeviceLogReader extends DeviceLogReader {
if
(
match
!=
null
)
{
final
String
logLine
=
line
.
substring
(
match
.
end
);
// Only display the log line after the initial device and executable information.
_
linesController
.
add
(
decodeSyslog
(
logLine
));
_
addToLinesController
(
decodeSyslog
(
logLine
));
printing
=
true
;
}
...
...
packages/flutter_tools/lib/src/ios/ios_deploy.dart
View file @
e99a66a4
...
...
@@ -383,7 +383,7 @@ class IOSDeployDebugger {
// 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...
}
else
{
}
else
if
(!
_debuggerOutput
.
isClosed
)
{
_debuggerOutput
.
add
(
line
);
}
lastLineFromDebugger
=
line
;
...
...
@@ -413,12 +413,16 @@ class IOSDeployDebugger {
}
on
ProcessException
catch
(
exception
,
stackTrace
)
{
_logger
.
printTrace
(
'ios-deploy failed:
$exception
'
);
_debuggerState
=
_IOSDeployDebuggerState
.
detached
;
if
(!
_debuggerOutput
.
isClosed
)
{
_debuggerOutput
.
addError
(
exception
,
stackTrace
);
}
}
on
ArgumentError
catch
(
exception
,
stackTrace
)
{
_logger
.
printTrace
(
'ios-deploy failed:
$exception
'
);
_debuggerState
=
_IOSDeployDebuggerState
.
detached
;
if
(!
_debuggerOutput
.
isClosed
)
{
_debuggerOutput
.
addError
(
exception
,
stackTrace
);
}
}
// Wait until the debugger attaches, or the attempt fails.
return
debuggerCompleter
.
future
;
}
...
...
packages/flutter_tools/test/general.shard/ios/ios_device_logger_test.dart
View file @
e99a66a4
...
...
@@ -7,6 +7,7 @@
import
'dart:async'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/base/async_guard.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/convert.dart'
;
...
...
@@ -309,6 +310,45 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
logReader
.
dispose
();
expect
(
iosDeployDebugger
.
detached
,
true
);
});
testWithoutContext
(
'Does not throw if debuggerStream set after logReader closed'
,
()
async
{
final
Stream
<
String
>
debuggingLogs
=
Stream
<
String
>.
fromIterable
(<
String
>[
'2020-09-15 19:15:10.931434-0700 Runner[541:226276] Did finish launching.'
,
'2020-09-15 19:15:10.931434-0700 Runner[541:226276] [Category] Did finish launching from logging category.'
,
'stderr from dart'
,
''
,
]);
final
IOSDeviceLogReader
logReader
=
IOSDeviceLogReader
.
test
(
iMobileDevice:
IMobileDevice
(
artifacts:
artifacts
,
processManager:
processManager
,
cache:
fakeCache
,
logger:
logger
,
),
useSyslog:
false
,
);
Object
exception
;
StackTrace
trace
;
await
asyncGuard
(
()
async
{
await
logReader
.
linesController
.
close
();
final
FakeIOSDeployDebugger
iosDeployDebugger
=
FakeIOSDeployDebugger
();
iosDeployDebugger
.
logLines
=
debuggingLogs
;
logReader
.
debuggerStream
=
iosDeployDebugger
;
await
logReader
.
logLines
.
drain
<
void
>();
},
onError:
(
Object
err
,
StackTrace
stackTrace
)
{
exception
=
err
;
trace
=
stackTrace
;
}
);
expect
(
exception
,
isNull
,
reason:
trace
.
toString
(),
);
});
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment