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
6e950672
Unverified
Commit
6e950672
authored
Aug 24, 2022
by
Christopher Fujino
Committed by
GitHub
Aug 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Fix _CastError in HotRunner._resetDirtyAssets (#108771)
parent
965912d8
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
390 additions
and
360 deletions
+390
-360
dds.dart
packages/flutter_tools/lib/src/base/dds.dart
+1
-0
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+87
-86
resident_web_runner.dart
...s/flutter_tools/lib/src/isolated/resident_web_runner.dart
+16
-15
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+13
-13
run_cold.dart
packages/flutter_tools/lib/src/run_cold.dart
+4
-4
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+22
-15
sksl_writer.dart
packages/flutter_tools/lib/src/sksl_writer.dart
+1
-1
vmservice.dart
packages/flutter_tools/lib/src/vmservice.dart
+2
-2
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+244
-224
No files found.
packages/flutter_tools/lib/src/base/dds.dart
View file @
6e950672
...
...
@@ -12,6 +12,7 @@ import 'context.dart';
import
'io.dart'
as
io
;
import
'logger.dart'
;
// TODO(fujino): This should be direct injected, rather than mutable global state.
@visibleForTesting
Future
<
dds
.
DartDevelopmentService
>
Function
(
Uri
remoteVmServiceUri
,
{
...
...
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
6e950672
This diff is collapsed.
Click to expand it.
packages/flutter_tools/lib/src/isolated/resident_web_runner.dart
View file @
6e950672
...
...
@@ -81,14 +81,14 @@ const String kExitMessage = 'Failed to establish connection with the application
class
ResidentWebRunner
extends
ResidentRunner
{
ResidentWebRunner
(
FlutterDevice
?
device
,
{
FlutterDevice
device
,
{
String
?
target
,
bool
stayResident
=
true
,
bool
machine
=
false
,
required
this
.
flutterProject
,
required
bool
?
ipv6
,
required
DebuggingOptions
debuggingOptions
,
required
FileSystem
?
fileSystem
,
required
FileSystem
fileSystem
,
required
Logger
?
logger
,
required
SystemClock
systemClock
,
required
Usage
usage
,
...
...
@@ -100,8 +100,8 @@ class ResidentWebRunner extends ResidentRunner {
_usage
=
usage
,
_urlTunneller
=
urlTunneller
,
super
(
<
FlutterDevice
?
>[
device
],
target:
target
??
fileSystem
!
.
path
.
join
(
'lib'
,
'main.dart'
),
<
FlutterDevice
>[
device
],
target:
target
??
fileSystem
.
path
.
join
(
'lib'
,
'main.dart'
),
debuggingOptions:
debuggingOptions
,
ipv6:
ipv6
,
stayResident:
stayResident
,
...
...
@@ -109,7 +109,7 @@ class ResidentWebRunner extends ResidentRunner {
devtoolsHandler:
devtoolsHandler
,
);
final
FileSystem
?
_fileSystem
;
final
FileSystem
_fileSystem
;
final
Logger
?
_logger
;
final
SystemClock
_systemClock
;
final
Usage
_usage
;
...
...
@@ -119,7 +119,7 @@ class ResidentWebRunner extends ResidentRunner {
Logger
?
get
logger
=>
_logger
;
@override
FileSystem
?
get
fileSystem
=>
_fileSystem
;
FileSystem
get
fileSystem
=>
_fileSystem
;
FlutterDevice
?
get
device
=>
flutterDevices
.
first
;
final
FlutterProject
flutterProject
;
...
...
@@ -245,7 +245,7 @@ class ResidentWebRunner extends ResidentRunner {
}
final
String
modeName
=
debuggingOptions
.
buildInfo
.
friendlyModeName
;
_logger
!.
printStatus
(
'Launching
${getDisplayPath(target, _fileSystem
!
)}
'
'Launching
${getDisplayPath(target, _fileSystem)}
'
'on
${device!.device!.name}
in
$modeName
mode...'
,
);
if
(
device
!.
device
is
ChromiumDevice
)
{
...
...
@@ -271,7 +271,7 @@ class ResidentWebRunner extends ResidentRunner {
buildInfo:
debuggingOptions
.
buildInfo
,
enableDwds:
_enableDwds
,
enableDds:
debuggingOptions
.
enableDds
,
entrypoint:
_fileSystem
!
.
file
(
target
).
uri
,
entrypoint:
_fileSystem
.
file
(
target
).
uri
,
expressionCompiler:
expressionCompiler
,
chromiumLauncher:
_chromiumLauncher
,
nullAssertions:
debuggingOptions
.
nullAssertions
,
...
...
@@ -425,7 +425,7 @@ class ResidentWebRunner extends ResidentRunner {
Future
<
Uri
>
_generateEntrypoint
(
Uri
mainUri
,
PackageConfig
?
packageConfig
)
async
{
File
?
result
=
_generatedEntrypointDirectory
?.
childFile
(
'web_entrypoint.dart'
);
if
(
_generatedEntrypointDirectory
==
null
)
{
_generatedEntrypointDirectory
??=
_fileSystem
!
.
systemTempDirectory
.
createTempSync
(
'flutter_tools.'
)
_generatedEntrypointDirectory
??=
_fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_tools.'
)
..
createSync
();
result
=
_generatedEntrypointDirectory
!.
childFile
(
'web_entrypoint.dart'
);
...
...
@@ -438,16 +438,17 @@ class ResidentWebRunner extends ResidentRunner {
Uri
?
importedEntrypoint
=
packageConfig
!.
toPackageUri
(
mainUri
);
// Special handling for entrypoints that are not under lib, such as test scripts.
if
(
importedEntrypoint
==
null
)
{
final
String
parent
=
_fileSystem
!.
file
(
mainUri
).
parent
.
path
;
flutterDevices
.
first
!.
generator
!.
addFileSystemRoot
(
parent
);
flutterDevices
.
first
!.
generator
!.
addFileSystemRoot
(
_fileSystem
!.
directory
(
'test'
).
absolute
.
path
);
final
String
parent
=
_fileSystem
.
file
(
mainUri
).
parent
.
path
;
flutterDevices
.
first
.
generator
!
..
addFileSystemRoot
(
parent
)
..
addFileSystemRoot
(
_fileSystem
.
directory
(
'test'
).
absolute
.
path
);
importedEntrypoint
=
Uri
(
scheme:
'org-dartlang-app'
,
path:
'/
${mainUri.pathSegments.last}
'
,
);
}
final
LanguageVersion
languageVersion
=
determineLanguageVersion
(
_fileSystem
!
.
file
(
mainUri
),
_fileSystem
.
file
(
mainUri
),
packageConfig
[
flutterProject
.
manifest
.
appName
],
Cache
.
flutterRoot
!,
);
...
...
@@ -487,7 +488,7 @@ class ResidentWebRunner extends ResidentRunner {
);
final
UpdateFSReport
report
=
await
device
!.
devFS
!.
update
(
mainUri:
await
_generateEntrypoint
(
_fileSystem
!
.
file
(
mainPath
).
absolute
.
uri
,
_fileSystem
.
file
(
mainPath
).
absolute
.
uri
,
invalidationResult
.
packageConfig
,
),
target:
target
,
...
...
@@ -603,7 +604,7 @@ class ResidentWebRunner extends ResidentRunner {
}
if
(
websocketUri
!=
null
)
{
if
(
debuggingOptions
.
vmserviceOutFile
!=
null
)
{
_fileSystem
!
.
file
(
debuggingOptions
.
vmserviceOutFile
)
_fileSystem
.
file
(
debuggingOptions
.
vmserviceOutFile
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
websocketUri
.
toString
());
}
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
6e950672
...
...
@@ -240,7 +240,7 @@ class FlutterDevice {
bool
cacheStartupProfile
=
false
,
bool
enableDds
=
true
,
required
bool
allowExistingDdsInstance
,
bool
?
ipv6
=
false
,
bool
ipv6
=
false
,
})
{
final
Completer
<
void
>
completer
=
Completer
<
void
>();
late
StreamSubscription
<
void
>
subscription
;
...
...
@@ -927,14 +927,14 @@ abstract class ResidentHandlers {
if
(!
supportsWriteSkSL
)
{
throw
Exception
(
'writeSkSL is not supported by this runner.'
);
}
final
List
<
FlutterView
>
views
=
await
flutterDevices
.
first
!
.
vmService
!
.
getFlutterViews
();
final
Map
<
String
,
Object
>
data
=
await
(
flutterDevices
.
first
!.
vmService
!
.
getSkSLs
(
final
FlutterDevice
flutterDevice
=
flutterDevices
.
first
!;
final
FlutterVmService
vmService
=
flutterDevice
.
vmService
!;
final
List
<
FlutterView
>
views
=
await
vmService
.
getFlutterViews
();
final
Map
<
String
,
Object
?>?
data
=
await
vmService
.
getSkSLs
(
viewId:
views
.
first
.
id
,
)
as
FutureOr
<
Map
<
String
,
Object
>>)
;
final
Device
device
=
flutterDevice
s
.
first
!
.
device
!;
return
sharedSkSlWriter
(
device
,
data
);
);
final
Device
device
=
flutterDevice
.
device
!;
return
sharedSkSlWriter
(
device
,
data
!
);
}
/// Take a screenshot on the provided [device].
...
...
@@ -1091,10 +1091,10 @@ abstract class ResidentRunner extends ResidentHandlers {
Logger
?
get
logger
=>
globals
.
logger
;
@override
FileSystem
?
get
fileSystem
=>
globals
.
fs
;
FileSystem
get
fileSystem
=>
globals
.
fs
;
@override
final
List
<
FlutterDevice
?
>
flutterDevices
;
final
List
<
FlutterDevice
>
flutterDevices
;
final
String
target
;
final
DebuggingOptions
debuggingOptions
;
...
...
@@ -1171,7 +1171,7 @@ abstract class ResidentRunner extends ResidentHandlers {
//
// Would be null if there is no device connected or
// there is no devFS associated with the first device.
Uri
?
get
uri
=>
flutterDevices
.
first
?
.
devFS
?.
baseUri
;
Uri
?
get
uri
=>
flutterDevices
.
first
.
devFS
?.
baseUri
;
/// Returns [true] if the resident runner exited after invoking [exit()].
bool
get
exited
=>
_exited
;
...
...
@@ -1257,7 +1257,7 @@ abstract class ResidentRunner extends ResidentHandlers {
void
writeVmServiceFile
()
{
if
(
debuggingOptions
.
vmserviceOutFile
!=
null
)
{
try
{
final
String
address
=
flutterDevices
.
first
!
.
vmService
!.
wsAddress
.
toString
();
final
String
address
=
flutterDevices
.
first
.
vmService
!.
wsAddress
.
toString
();
final
File
vmserviceOutFile
=
globals
.
fs
.
file
(
debuggingOptions
.
vmserviceOutFile
);
vmserviceOutFile
.
createSync
(
recursive:
true
);
vmserviceOutFile
.
writeAsStringSync
(
address
);
...
...
@@ -1359,7 +1359,7 @@ abstract class ResidentRunner extends ResidentHandlers {
hostVmServicePort:
debuggingOptions
.
hostVmServicePort
,
getSkSLMethod:
getSkSLMethod
,
printStructuredErrorLogMethod:
printStructuredErrorLog
,
ipv6:
ipv6
,
ipv6:
ipv6
??
false
,
disableServiceAuthCodes:
debuggingOptions
.
disableServiceAuthCodes
,
cacheStartupProfile:
debuggingOptions
.
cacheStartupProfile
,
);
...
...
packages/flutter_tools/lib/src/run_cold.dart
View file @
6e950672
...
...
@@ -88,11 +88,11 @@ class ColdRunner extends ResidentRunner {
));
}
if
(
flutterDevices
.
first
!
.
observatoryUris
!=
null
)
{
if
(
flutterDevices
.
first
.
observatoryUris
!=
null
)
{
// For now, only support one debugger connection.
connectionInfoCompleter
?.
complete
(
DebugConnectionInfo
(
httpUri:
flutterDevices
.
first
!
.
vmService
!.
httpAddress
,
wsUri:
flutterDevices
.
first
!
.
vmService
!.
wsAddress
,
httpUri:
flutterDevices
.
first
.
vmService
!.
httpAddress
,
wsUri:
flutterDevices
.
first
.
vmService
!.
wsAddress
,
));
}
...
...
@@ -108,7 +108,7 @@ class ColdRunner extends ResidentRunner {
if
(
traceStartup
)
{
// Only trace startup for the first device.
final
FlutterDevice
device
=
flutterDevices
.
first
!
;
final
FlutterDevice
device
=
flutterDevices
.
first
;
if
(
device
.
vmService
!=
null
)
{
globals
.
printStatus
(
'Tracing startup on
${device.device!.name}
.'
);
final
String
outputPath
=
globals
.
platform
.
environment
[
kFlutterTestOutputsDirEnvName
]
??
getBuildDirectory
();
...
...
packages/flutter_tools/lib/src/run_hot.dart
View file @
6e950672
...
...
@@ -141,7 +141,7 @@ class HotRunner extends ResidentRunner {
}
if
(
flutterDevices
.
length
==
1
)
{
final
Device
device
=
flutterDevices
.
first
!
.
device
!;
final
Device
device
=
flutterDevices
.
first
.
device
!;
_targetPlatform
=
getNameForTargetPlatform
(
await
device
.
targetPlatform
);
_sdkName
=
await
device
.
sdkNameAndVersion
;
_emulator
=
await
device
.
isLocalEmulator
;
...
...
@@ -257,8 +257,8 @@ class HotRunner extends ResidentRunner {
// Only handle one debugger connection.
connectionInfoCompleter
.
complete
(
DebugConnectionInfo
(
httpUri:
flutterDevices
.
first
!
.
vmService
!.
httpAddress
,
wsUri:
flutterDevices
.
first
!
.
vmService
!.
wsAddress
,
httpUri:
flutterDevices
.
first
.
vmService
!.
httpAddress
,
wsUri:
flutterDevices
.
first
.
vmService
!.
wsAddress
,
baseUri:
baseUris
.
first
.
toString
(),
),
);
...
...
@@ -454,12 +454,13 @@ class HotRunner extends ResidentRunner {
}
final
Stopwatch
findInvalidationTimer
=
_stopwatchFactory
.
createStopwatch
(
'updateDevFS'
)..
start
();
final
DevFS
devFS
=
flutterDevices
[
0
].
devFS
!;
final
InvalidationResult
invalidationResult
=
await
projectFileInvalidator
.
findInvalidated
(
lastCompiled:
flutterDevices
[
0
]!.
devFS
!
.
lastCompiled
,
urisToMonitor:
flutterDevices
[
0
]!.
devFS
!
.
sources
,
lastCompiled:
devFS
.
lastCompiled
,
urisToMonitor:
devFS
.
sources
,
packagesPath:
packagesFilePath
,
asyncScanning:
hotRunnerConfig
!.
asyncScanning
,
packageConfig:
flutterDevices
[
0
]!.
devFS
!
.
lastPackageConfig
packageConfig:
devFS
.
lastPackageConfig
??
debuggingOptions
.
buildInfo
.
packageConfig
,
);
findInvalidationTimer
.
stop
();
...
...
@@ -474,7 +475,7 @@ class HotRunner extends ResidentRunner {
}
final
UpdateFSReport
results
=
UpdateFSReport
(
success:
true
,
scannedSourcesCount:
flutterDevices
[
0
]!.
devFS
!
.
sources
.
length
,
scannedSourcesCount:
devFS
.
sources
.
length
,
findInvalidatedDuration:
findInvalidationTimer
.
elapsed
,
);
for
(
final
FlutterDevice
?
device
in
flutterDevices
)
{
...
...
@@ -497,21 +498,27 @@ class HotRunner extends ResidentRunner {
}
void
_resetDirtyAssets
()
{
for
(
final
FlutterDevice
?
device
in
flutterDevices
)
{
device
!.
devFS
!.
assetPathsToEvict
.
clear
();
device
.
devFS
!.
shaderPathsToEvict
.
clear
();
for
(
final
FlutterDevice
device
in
flutterDevices
)
{
final
DevFS
?
devFS
=
device
.
devFS
;
if
(
devFS
==
null
)
{
// This is sometimes null, however we don't know why and have not been
// able to reproduce, https://github.com/flutter/flutter/issues/108653
continue
;
}
devFS
.
assetPathsToEvict
.
clear
();
devFS
.
shaderPathsToEvict
.
clear
();
}
}
Future
<
void
>
_cleanupDevFS
()
async
{
final
List
<
Future
<
void
>>
futures
=
<
Future
<
void
>>[];
for
(
final
FlutterDevice
?
device
in
flutterDevices
)
{
if
(
device
!
.
devFS
!=
null
)
{
for
(
final
FlutterDevice
device
in
flutterDevices
)
{
if
(
device
.
devFS
!=
null
)
{
// Cleanup the devFS, but don't wait indefinitely.
// We ignore any errors, because it's not clear what we would do anyway.
futures
.
add
(
device
.
devFS
!.
destroy
()
.
timeout
(
const
Duration
(
milliseconds:
250
))
.
catchError
((
dynamic
error
)
{
.
catchError
((
Object
?
error
)
{
globals
.
printTrace
(
'Ignored error while cleaning up DevFS:
$error
'
);
}));
}
...
...
@@ -756,7 +763,7 @@ class HotRunner extends ResidentRunner {
String
?
restartEvent
;
try
{
final
Stopwatch
restartTimer
=
_stopwatchFactory
.
createStopwatch
(
'fullRestartHelper'
)..
start
();
if
(
!(
await
(
hotRunnerConfig
!.
setupHotRestart
()
as
FutureOr
<
bool
>))
)
{
if
(
(
await
hotRunnerConfig
!.
setupHotRestart
())
!=
true
)
{
return
OperationResult
(
1
,
'setupHotRestart failed'
);
}
result
=
await
_restartFromSources
(
reason:
reason
);
...
...
@@ -885,7 +892,7 @@ class HotRunner extends ResidentRunner {
}
final
Stopwatch
reloadTimer
=
_stopwatchFactory
.
createStopwatch
(
'reloadSources:reload'
)..
start
();
if
(
!(
await
(
hotRunnerConfig
!.
setupHotReload
()
as
FutureOr
<
bool
>))
)
{
if
(
(
await
hotRunnerConfig
!.
setupHotReload
())
!=
true
)
{
return
OperationResult
(
1
,
'setupHotReload failed'
);
}
final
Stopwatch
devFSTimer
=
Stopwatch
()..
start
();
...
...
packages/flutter_tools/lib/src/sksl_writer.dart
View file @
6e950672
...
...
@@ -13,7 +13,7 @@ import 'convert.dart';
import
'device.dart'
;
import
'globals.dart'
as
globals
;
Future
<
String
?>
sharedSkSlWriter
(
Device
device
,
Map
<
String
,
Object
>
data
,
{
Future
<
String
?>
sharedSkSlWriter
(
Device
device
,
Map
<
String
,
Object
?
>
data
,
{
File
?
outputFile
,
Logger
?
logger
,
})
async
{
...
...
packages/flutter_tools/lib/src/vmservice.dart
View file @
6e950672
...
...
@@ -493,7 +493,7 @@ class FlutterVmService {
///
/// This method will only return data if `--cache-sksl` was provided as a
/// flutter run argument, and only then on physical devices.
Future
<
Map
<
String
,
Object
>?>
getSkSLs
({
Future
<
Map
<
String
,
Object
?
>?>
getSkSLs
({
required
String
viewId
,
})
async
{
final
vm_service
.
Response
?
response
=
await
callMethodWrapper
(
...
...
@@ -505,7 +505,7 @@ class FlutterVmService {
if
(
response
==
null
)
{
return
null
;
}
return
response
.
json
?[
'SkSLs'
]
as
Map
<
String
,
Object
>?;
return
response
.
json
?[
'SkSLs'
]
as
Map
<
String
,
Object
?
>?;
}
/// Flush all tasks on the UI thread for an attached Flutter view.
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
6e950672
This diff is collapsed.
Click to expand it.
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