-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[flutter_tools] Fix _CastError in HotRunner._resetDirtyAssets #108771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -498,8 +498,8 @@ class HotRunner extends ResidentRunner { | |||
|
|||
void _resetDirtyAssets() { | |||
for (final FlutterDevice? device in flutterDevices) { | |||
device!.devFS!.assetPathsToEvict.clear(); | |||
device.devFS!.shaderPathsToEvict.clear(); | |||
device!.devFS?.assetPathsToEvict.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the !
to a ?
here was the fix. I'm not sure why the devFS is null here. The rest of the diffs here are related to migrating the test to null-safety and getting the tests to pass.
@jmagman sorry, this is a meaty PR, enabling null-safety on the test file I needed to make a lot of changes just to get it to compile (and then many more to get the tests to pass). |
@@ -498,8 +498,8 @@ class HotRunner extends ResidentRunner { | |||
|
|||
void _resetDirtyAssets() { | |||
for (final FlutterDevice? device in flutterDevices) { | |||
device!.devFS!.assetPathsToEvict.clear(); | |||
device.devFS!.shaderPathsToEvict.clear(); | |||
device!.devFS?.assetPathsToEvict.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devFS can be null if we hit this code path either before the device has been set up or after its been torn down. The latter seems more likely - perhaps if the user triggers a reload that stalls and then they exit? We hit this issue before and I was never able to repro, in that case something like the following would be more obvious for future readers.
final DevFS? devfs = device.devFS;
if (devfs == null) {
// note about why this happens
continue;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM, however I have no idea why it happens. Should I just link to the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that is a reasonable approach. We need this null check to prevent a crash, but we don't know why exactly see issue# or somesuch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
packages/flutter_tools/lib/src/isolated/resident_web_runner.dart
Outdated
Show resolved
Hide resolved
c3607a8
to
2e20c4f
Compare
Fixes #108653