Skip to content

[State Restoration] RestorableListener causes Dart compiler crash upon hot reload #72700

@shihaohong

Description

@shihaohong

First discovered when migrating the gallery to make use of state restoration: flutter/gallery#389.

This issue is seen in the Reply and Shrine mini apps, both of which use state management packages (provider and scoped_model).

Reproducible sample: https://github.com/shihaohong/state_restoration_provider_crash

Steps to reproduce:

  1. Run the Flutter application
  2. Make any changes to the code in your IDE (ie. adding spaces after a line of code) and save.
  3. Hot Reload

Stack trace:

Unhandled exception:
root::package:hot_reload_crash/main.dart::_RestorableCounterState::@methods::package:flutter/src/widgets/restoration.dart::_debugAssertNotDisposed is already bound
#0      CanonicalName.bindTo (package:kernel/canonical_name.dart:192:7)
#1      Class.computeCanonicalNames (package:kernel/ast.dart:1201:51)
#2      Library.computeCanonicalNames (package:kernel/ast.dart:559:14)
#3      Component.computeCanonicalNamesForLibrary (package:kernel/ast.dart:10821:13)
#4      Component.computeCanonicalNames (package:kernel/ast.dart:10783:7)
#5      sortComponent (package:vm/kernel_front_end.dart:679:13)

#6      FrontendCompiler.writeDillFile (package:frontend_server/frontend_server.dart:656:5)
#7      FrontendCompiler.recompileDelta (package:frontend_server/frontend_server.dart:766:13)

I also noticed that this only happens when hot reload is called in the Dart files where _RestorableCounterState is defined. The sample all only has one Dart file, but in the gallery app, this is more apparent since changes to files that do not contain the RestorableListenable class do not trigger the crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: state restorationRestorationManager and related APIsc: crashStack traces logged to the consolet: hot reloadReloading code during "flutter run"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions