Skip to content
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

FormatException: Message corrupted in StandardMessageCodec.readValue during state restoration #147456

Open
seelrd opened this issue Apr 27, 2024 · 0 comments · May be fixed by #147458
Open

FormatException: Message corrupted in StandardMessageCodec.readValue during state restoration #147456

seelrd opened this issue Apr 27, 2024 · 0 comments · May be fixed by #147458
Labels
a: state restoration RestorationManager and related APIs c: crash Stack traces logged to the console framework flutter/packages/flutter repository. See also f: labels. needs repro info Automated crash report whose cause isn't yet known P3 Issues that are less important to the Flutter project team-framework Owned by Framework team triaged-framework Triaged by Framework team

Comments

@seelrd
Copy link

seelrd commented Apr 27, 2024

Steps to reproduce

Can't reproduce, but my app is using simple restorable variables (RestorableString, etc.) and navigator.restorablePush functions.

Expected results

Shouldn't crash during state restoration.
This is a very rare problem.

Actual results

App crashes on iOS during fresh app start very rarely.
The error is "FormatException: Message corrupted" in StandardMessageCodec.readValue (you can see it in the logs below) during state restoration. I have no other logs, as the app crashes immediately (at state restoration), none of my code runs.

As writing an incorrect value to a restorable variable would cause an error while modifying the variable, and an error like that doesn't occur, I believe this is a bug in Flutter.

Code sample

Code sample
Navigator.of(context).restorablePush(ConversationPage.routeBuilder,
                arguments: {'conversation': conversation.toJSON()});
late RestorableTextEditingController inputController;
RestorableInt replyMessageId = RestorableInt(0);
  RestorableString chatInput = RestorableString("");
RestorableBool isSendingImage = RestorableBool(false);
 @override
  void initState() {
    super.initState();

    inputController = RestorableTextEditingController();
}
@override
  void dispose() {
    inputController.dispose();
    super.dispose();
  }
@override
  void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
    registerForRestoration(chatInput, 'chatInput');
    registerForRestoration(inputController, 'inputController');
    registerForRestoration(replyMessageId, 'replyMessageId');
    registerForRestoration(isSendingImage, 'isSendingImage');

    String savedInput =
        context.read<DataCubit>().chatInputs[widget.conversation.id] ?? "";
    if (inputController.value.text.isEmpty && savedInput.isNotEmpty) {
      inputController.value.text = savedInput;
      chatInput.value = savedInput;
    }
  }

Screenshots or Video

Screenshots / Video demonstration

437038965_411982418270517_8298018276426356937_n

Logs

Logs
Fatal Exception: FlutterError
0  ???                            0x0 StandardMessageCodec.readValue + 474 (message_codecs.dart:474)
1  ???                            0x0 StandardMessageCodec.decodeMessage + 341 (message_codecs.dart:341)
2  ???                            0x0 RestorationManager._decodeRestorationData + 322 (restoration.dart:322)
3  ???                            0x0 RestorationManager.handleRestorationUpdateFromEngine + 276 (restoration.dart:276)
4  ???                            0x0 RestorationManager._parseAndHandleRestorationUpdateFromEngine + 243 (restoration.dart:243)
5  ???                            0x0 RestorationManager._getRootBucketFromEngine + 239 (restoration.dart:239)

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.5, on macOS 14.4.1 23E224 darwin-arm64, locale hu-HU)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      flutter config --android-sdk to update to that location.

[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google [Chrome.app/Contents/MacOS/Google](http://chrome.app/Contents/MacOS/Google) Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[!] Android Studio (not installed)
[✓] VS Code (version 1.88.1)
[✓] Connected device (2 available)
[✓] Network resources

! Doctor found issues in 3 categories.
@darshankawar darshankawar added in triage Presently being triaged by the triage team c: crash Stack traces logged to the console framework flutter/packages/flutter repository. See also f: labels. needs repro info Automated crash report whose cause isn't yet known team-framework Owned by Framework team and removed in triage Presently being triaged by the triage team labels Apr 29, 2024
@goderbauer goderbauer added P3 Issues that are less important to the Flutter project a: state restoration RestorationManager and related APIs triaged-framework Triaged by Framework team labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: state restoration RestorationManager and related APIs c: crash Stack traces logged to the console framework flutter/packages/flutter repository. See also f: labels. needs repro info Automated crash report whose cause isn't yet known P3 Issues that are less important to the Flutter project team-framework Owned by Framework team triaged-framework Triaged by Framework team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants