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
5655225c
Unverified
Commit
5655225c
authored
Sep 29, 2022
by
Danny Tuppeny
Committed by
GitHub
Sep 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send progress notifications to clients during hot reload / hot restart (#112455)
parent
a11bef96
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
0 deletions
+109
-0
flutter_adapter.dart
...flutter_tools/lib/src/debug_adapters/flutter_adapter.dart
+25
-0
flutter_adapter_args.dart
...er_tools/lib/src/debug_adapters/flutter_adapter_args.dart
+2
-0
flutter_adapter_test.dart
...integration.shard/debug_adapter/flutter_adapter_test.dart
+74
-0
test_client.dart
...ols/test/integration.shard/debug_adapter/test_client.dart
+8
-0
No files found.
packages/flutter_tools/lib/src/debug_adapters/flutter_adapter.dart
View file @
5655225c
...
...
@@ -140,6 +140,13 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
Future
<
void
>
attachImpl
()
async
{
final
FlutterAttachRequestArguments
args
=
this
.
args
as
FlutterAttachRequestArguments
;
final
DapProgressReporter
progress
=
startProgressNotification
(
'launch'
,
'Flutter'
,
message:
'Attaching…'
,
);
unawaited
(
appStartedCompleter
.
future
.
then
((
_
)
=>
progress
.
end
()));
final
String
?
vmServiceUri
=
args
.
vmServiceUri
;
final
List
<
String
>
toolArgs
=
<
String
>[
'attach'
,
...
...
@@ -255,6 +262,13 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
Future
<
void
>
launchImpl
()
async
{
final
FlutterLaunchRequestArguments
args
=
this
.
args
as
FlutterLaunchRequestArguments
;
final
DapProgressReporter
progress
=
startProgressNotification
(
'launch'
,
'Flutter'
,
message:
'Launching…'
,
);
unawaited
(
appStartedCompleter
.
future
.
then
((
_
)
=>
progress
.
end
()));
final
List
<
String
>
toolArgs
=
<
String
>[
'run'
,
'--machine'
,
...
...
@@ -593,6 +607,14 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
bool
fullRestart
,
[
String
?
reason
,
])
async
{
final
String
progressId
=
fullRestart
?
'hotRestart'
:
'hotReload'
;
final
String
progressMessage
=
fullRestart
?
'Hot restarting…'
:
'Hot reloading…'
;
final
DapProgressReporter
progress
=
startProgressNotification
(
progressId
,
'Flutter'
,
message:
progressMessage
,
);
try
{
await
sendFlutterRequest
(
'app.restart'
,
<
String
,
Object
?>{
'appId'
:
appId
,
...
...
@@ -605,6 +627,9 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
final
String
action
=
fullRestart
?
'Hot Restart'
:
'Hot Reload'
;
sendOutput
(
'console'
,
'Failed to
$action
:
$error
'
);
}
finally
{
progress
.
end
();
}
}
void
_sendServiceExtensionStateChanged
(
vm
.
ExtensionData
?
extensionData
)
{
...
...
packages/flutter_tools/lib/src/debug_adapters/flutter_adapter_args.dart
View file @
5655225c
...
...
@@ -27,6 +27,7 @@ class FlutterAttachRequestArguments
super
.
evaluateGettersInDebugViews
,
super
.
evaluateToStringInDebugViews
,
super
.
sendLogsToClient
,
super
.
sendCustomProgressEvents
,
});
FlutterAttachRequestArguments
.
fromMap
(
super
.
obj
)
...
...
@@ -99,6 +100,7 @@ class FlutterLaunchRequestArguments
super
.
evaluateGettersInDebugViews
,
super
.
evaluateToStringInDebugViews
,
super
.
sendLogsToClient
,
super
.
sendCustomProgressEvents
,
});
FlutterLaunchRequestArguments
.
fromMap
(
super
.
obj
)
...
...
packages/flutter_tools/test/integration.shard/debug_adapter/flutter_adapter_test.dart
View file @
5655225c
...
...
@@ -218,6 +218,43 @@ void main() {
await
dap
.
client
.
terminate
();
});
testWithoutContext
(
'sends progress notifications during hot reload'
,
()
async
{
final
BasicProject
project
=
BasicProject
();
await
project
.
setUpIn
(
tempDir
);
// Launch the app and wait for it to print "topLevelFunction".
await
Future
.
wait
(<
Future
<
void
>>[
dap
.
client
.
stdoutOutput
.
firstWhere
((
String
output
)
=>
output
.
startsWith
(
'topLevelFunction'
)),
dap
.
client
.
initialize
(
supportsProgressReporting:
true
),
dap
.
client
.
launch
(
cwd:
project
.
dir
.
path
,
noDebug:
true
,
toolArgs:
<
String
>[
'-d'
,
'flutter-tester'
],
),
],
eagerError:
true
);
// Capture progress events during a reload.
final
Future
<
List
<
Event
>>
progressEventsFuture
=
dap
.
client
.
progressEvents
().
toList
();
await
dap
.
client
.
hotReload
();
await
dap
.
client
.
terminate
();
// Verify the progress events.
final
List
<
Event
>
progressEvents
=
await
progressEventsFuture
;
expect
(
progressEvents
,
hasLength
(
2
));
final
List
<
String
>
eventKinds
=
progressEvents
.
map
((
Event
event
)
=>
event
.
event
).
toList
();
expect
(
eventKinds
,
<
String
>[
'progressStart'
,
'progressEnd'
]);
final
List
<
Map
<
String
,
Object
?>>
eventBodies
=
progressEvents
.
map
((
Event
event
)
=>
event
.
body
).
cast
<
Map
<
String
,
Object
?>>().
toList
();
final
ProgressStartEventBody
start
=
ProgressStartEventBody
.
fromMap
(
eventBodies
[
0
]);
final
ProgressEndEventBody
end
=
ProgressEndEventBody
.
fromMap
(
eventBodies
[
1
]);
expect
(
start
.
progressId
,
isNotNull
);
expect
(
start
.
title
,
'Flutter'
);
expect
(
start
.
message
,
'Hot reloading…'
);
expect
(
end
.
progressId
,
start
.
progressId
);
expect
(
end
.
message
,
isNull
);
});
testWithoutContext
(
'can hot restart'
,
()
async
{
final
BasicProject
project
=
BasicProject
();
await
project
.
setUpIn
(
tempDir
);
...
...
@@ -255,6 +292,43 @@ void main() {
await
dap
.
client
.
terminate
();
});
testWithoutContext
(
'sends progress notifications during hot restart'
,
()
async
{
final
BasicProject
project
=
BasicProject
();
await
project
.
setUpIn
(
tempDir
);
// Launch the app and wait for it to print "topLevelFunction".
await
Future
.
wait
(<
Future
<
void
>>[
dap
.
client
.
stdoutOutput
.
firstWhere
((
String
output
)
=>
output
.
startsWith
(
'topLevelFunction'
)),
dap
.
client
.
initialize
(
supportsProgressReporting:
true
),
dap
.
client
.
launch
(
cwd:
project
.
dir
.
path
,
noDebug:
true
,
toolArgs:
<
String
>[
'-d'
,
'flutter-tester'
],
),
],
eagerError:
true
);
// Capture progress events during a restart.
final
Future
<
List
<
Event
>>
progressEventsFuture
=
dap
.
client
.
progressEvents
().
toList
();
await
dap
.
client
.
hotRestart
();
await
dap
.
client
.
terminate
();
// Verify the progress events.
final
List
<
Event
>
progressEvents
=
await
progressEventsFuture
;
expect
(
progressEvents
,
hasLength
(
2
));
final
List
<
String
>
eventKinds
=
progressEvents
.
map
((
Event
event
)
=>
event
.
event
).
toList
();
expect
(
eventKinds
,
<
String
>[
'progressStart'
,
'progressEnd'
]);
final
List
<
Map
<
String
,
Object
?>>
eventBodies
=
progressEvents
.
map
((
Event
event
)
=>
event
.
body
).
cast
<
Map
<
String
,
Object
?>>().
toList
();
final
ProgressStartEventBody
start
=
ProgressStartEventBody
.
fromMap
(
eventBodies
[
0
]);
final
ProgressEndEventBody
end
=
ProgressEndEventBody
.
fromMap
(
eventBodies
[
1
]);
expect
(
start
.
progressId
,
isNotNull
);
expect
(
start
.
title
,
'Flutter'
);
expect
(
start
.
message
,
'Hot restarting…'
);
expect
(
end
.
progressId
,
start
.
progressId
);
expect
(
end
.
message
,
isNull
);
});
testWithoutContext
(
'can hot restart when exceptions occur on outgoing isolates'
,
()
async
{
final
BasicProjectThatThrows
project
=
BasicProjectThatThrows
();
await
project
.
setUpIn
(
tempDir
);
...
...
packages/flutter_tools/test/integration.shard/debug_adapter/test_client.dart
View file @
5655225c
...
...
@@ -83,6 +83,12 @@ class DapTestClient {
return
_eventController
.
stream
.
where
((
Event
e
)
=>
e
.
event
==
event
);
}
/// Returns a stream of progress events.
Stream
<
Event
>
progressEvents
()
{
const
Set
<
String
>
progressEvents
=
<
String
>{
'progressStart'
,
'progressUpdate'
,
'progressEnd'
};
return
_eventController
.
stream
.
where
((
Event
e
)
=>
progressEvents
.
contains
(
e
.
event
));
}
/// Returns a stream of custom 'dart.serviceExtensionAdded' events.
Stream
<
Map
<
String
,
Object
?>>
get
serviceExtensionAddedEvents
=>
events
(
'dart.serviceExtensionAdded'
)
...
...
@@ -116,12 +122,14 @@ class DapTestClient {
Future
<
Response
>
initialize
({
String
exceptionPauseMode
=
'None'
,
bool
?
supportsRunInTerminalRequest
,
bool
?
supportsProgressReporting
,
})
async
{
final
List
<
ProtocolMessage
>
responses
=
await
Future
.
wait
(<
Future
<
ProtocolMessage
>>[
event
(
'initialized'
),
sendRequest
(
InitializeRequestArguments
(
adapterID:
'test'
,
supportsRunInTerminalRequest:
supportsRunInTerminalRequest
,
supportsProgressReporting:
supportsProgressReporting
,
)),
sendRequest
(
SetExceptionBreakpointsArguments
(
...
...
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