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
9ba06b4d
Unverified
Commit
9ba06b4d
authored
Jan 25, 2021
by
Jonah Williams
Committed by
GitHub
Jan 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] handle waitForExtension having no isolates (#74664)
parent
5d8dfa44
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
22 deletions
+104
-22
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+24
-22
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+80
-0
No files found.
packages/flutter_tools/lib/src/resident_runner.dart
View file @
9ba06b4d
...
...
@@ -1450,34 +1450,36 @@ abstract class ResidentRunner {
// Clears the screen.
void
clearScreen
()
=>
globals
.
logger
.
clear
();
}
Future
<
vm_service
.
Isolate
>
waitForExtension
(
vm_service
.
VmService
vmService
,
String
extension
)
async
{
final
Completer
<
void
>
completer
=
Completer
<
void
>();
try
{
await
vmService
.
streamListen
(
vm_service
.
EventStreams
.
kExtension
);
}
on
Exception
{
// do nothing
}
StreamSubscription
<
vm_service
.
Event
>
extensionStream
;
extensionStream
=
vmService
.
onExtensionEvent
.
listen
((
vm_service
.
Event
event
)
{
if
(
event
.
json
[
'extensionKind'
]
==
'Flutter.FrameworkInitialization'
)
{
// The 'Flutter.FrameworkInitialization' event is sent on hot restart
// as well, so make sure we don't try to complete this twice.
if
(!
completer
.
isCompleted
)
{
completer
.
complete
();
extensionStream
.
cancel
();
}
@visibleForTesting
Future
<
void
>
waitForExtension
(
vm_service
.
VmService
vmService
,
String
extension
)
async
{
final
Completer
<
void
>
completer
=
Completer
<
void
>();
try
{
await
vmService
.
streamListen
(
vm_service
.
EventStreams
.
kExtension
);
}
on
Exception
{
// do nothing
}
StreamSubscription
<
vm_service
.
Event
>
extensionStream
;
extensionStream
=
vmService
.
onExtensionEvent
.
listen
((
vm_service
.
Event
event
)
{
if
(
event
.
json
[
'extensionKind'
]
==
'Flutter.FrameworkInitialization'
)
{
// The 'Flutter.FrameworkInitialization' event is sent on hot restart
// as well, so make sure we don't try to complete this twice.
if
(!
completer
.
isCompleted
)
{
completer
.
complete
();
extensionStream
.
cancel
();
}
});
final
vm_service
.
IsolateRef
isolateRef
=
(
await
vmService
.
getVM
()).
isolates
.
first
;
}
});
final
vm_service
.
VM
vm
=
await
vmService
.
getVM
();
if
(
vm
.
isolates
.
isNotEmpty
)
{
final
vm_service
.
IsolateRef
isolateRef
=
vm
.
isolates
.
first
;
final
vm_service
.
Isolate
isolate
=
await
vmService
.
getIsolate
(
isolateRef
.
id
);
if
(
isolate
.
extensionRPCs
.
contains
(
extension
))
{
return
isolate
;
return
;
}
await
completer
.
future
;
return
isolate
;
}
await
completer
.
future
;
}
class
OperationResult
{
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
9ba06b4d
...
...
@@ -3001,6 +3001,86 @@ void main() {
expect
(
nextPlatform
(
'fuchsia'
,
TestFeatureFlags
(
isMacOSEnabled:
true
)),
'macOS'
);
expect
(()
=>
nextPlatform
(
'unknown'
,
TestFeatureFlags
()),
throwsAssertionError
);
});
testWithoutContext
(
'wait for extension handles an immediate extension'
,
()
{
final
vm_service
.
Isolate
isolate
=
vm_service
.
Isolate
(
id:
'1'
,
pauseEvent:
vm_service
.
Event
(
kind:
vm_service
.
EventKind
.
kResume
,
timestamp:
0
),
breakpoints:
<
vm_service
.
Breakpoint
>[],
exceptionPauseMode:
null
,
libraries:
<
vm_service
.
LibraryRef
>[
vm_service
.
LibraryRef
(
id:
'1'
,
uri:
'file:///hello_world/main.dart'
,
name:
''
,
),
],
livePorts:
0
,
name:
'test'
,
number:
'1'
,
pauseOnExit:
false
,
runnable:
true
,
startTime:
0
,
isSystemIsolate:
false
,
isolateFlags:
<
vm_service
.
IsolateFlag
>[],
extensionRPCs:
<
String
>[
'foo'
]
);
final
FakeVmServiceHost
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
const
FakeVmServiceRequest
(
method:
'streamListen'
,
args:
<
String
,
Object
>{
'streamId'
:
'Extension'
,
}
),
FakeVmServiceRequest
(
method:
'getVM'
,
jsonResponse:
fakeVM
.
toJson
()),
FakeVmServiceRequest
(
method:
'getIsolate'
,
jsonResponse:
isolate
.
toJson
(),
args:
<
String
,
Object
>{
'isolateId'
:
'1'
,
},
),
]);
waitForExtension
(
fakeVmServiceHost
.
vmService
,
'foo'
);
});
testWithoutContext
(
'wait for extension handles no isolates'
,
()
{
final
FakeVmServiceHost
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
const
FakeVmServiceRequest
(
method:
'streamListen'
,
args:
<
String
,
Object
>{
'streamId'
:
'Extension'
,
}
),
FakeVmServiceRequest
(
method:
'getVM'
,
jsonResponse:
vm_service
.
VM
(
isolates:
<
vm_service
.
IsolateRef
>[],
pid:
1
,
hostCPU:
''
,
isolateGroups:
<
vm_service
.
IsolateGroupRef
>[],
targetCPU:
''
,
startTime:
0
,
name:
'dart'
,
architectureBits:
64
,
operatingSystem:
''
,
version:
''
,
systemIsolateGroups:
<
vm_service
.
IsolateGroupRef
>[],
systemIsolates:
<
vm_service
.
IsolateRef
>[],
).
toJson
()),
FakeVmServiceStreamResponse
(
streamId:
'Extension'
,
event:
vm_service
.
Event
(
timestamp:
0
,
extensionKind:
'Flutter.FrameworkInitialization'
,
kind:
'test'
,
),
),
]);
waitForExtension
(
fakeVmServiceHost
.
vmService
,
'foo'
);
});
}
class
MockFlutterDevice
extends
Mock
implements
FlutterDevice
{}
...
...
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