Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 12 commits into from
Aug 24, 2022

Conversation

christopherfujino
Copy link
Contributor

Fixes #108653

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 1, 2022
@@ -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();
Copy link
Contributor Author

@christopherfujino christopherfujino Aug 1, 2022

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.

@christopherfujino christopherfujino marked this pull request as ready for review August 2, 2022 17:03
@christopherfujino
Copy link
Contributor Author

@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();
Copy link
Member

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;
}

Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[flutter_tools] _CastError in HotRunner._resetDirtyAssets
3 participants