Skip to content

setState called when widget is not mounted on MultiFrameImage emitter #71344

Open

Description

@mehmetf

Internal: b/174211205

customer:money is rarely seeing this crash (14 times within 4 weeks):

Thread 0 main thread_CastError: Null check operator used on a null value
at State.setState(framework.dart:1289)
at _ImageState._handleImageFrame(image.dart:1188)
at ImageStreamCompleter.setImage(image_stream.dart:616)
at MultiFrameImageStreamCompleter._emitFrame(image_stream.dart:946)
at MultiFrameImageStreamCompleter._decodeNextFrameAndSchedule(image_stream.dart:925)
at <asynchronous gap>(async)

Seems like there's a race between image frames being emitted and the widget being disposed.

Activity

  1. added
    c: crashStack traces logged to the console
    frameworkflutter/packages/flutter repository. See also f: labels.
    P1High-priority issues at the top of the work list
    on Nov 28, 2020
  2. goderbauer commented on Dec 9, 2020

    @goderbauer
    Member
  3. dnfield commented on Dec 9, 2020

    @dnfield
    Contributor

    I assume this is happening in non-debug modes? There are asserts higher up that should be triggered if it were to happen when asserts are enabled.

  4. dnfield commented on Dec 9, 2020

    @dnfield
    Contributor

    We could add some more defensive code before calling setState, but we should be doing everything correctly here and I'd like to understand better why this is happening.

    In ImageState.dispose, we're unsubscribing from the stream. That should prevent further calls to _handleImageFrame.

    The only thing I can think of is if we're somehow leaving a stray listener on the stream, but we shouldn't be.

    It'd really help to have a reproduction for this.

  5. mehmetf commented on Dec 11, 2020

    @mehmetf
    ContributorAuthor

    We don't have repro unfortunately. It happens rarely in the wild (i.e. release mode). If nothing jumps out at you, we can close this. If the crash rates increase, we can revisit and hopefully have a repro.

  6. mehmetf commented on Dec 11, 2020

    @mehmetf
    ContributorAuthor

    On second thought, let's keep it open since closing this will also close the internal bug.

  7. dnfield commented on Dec 11, 2020

    @dnfield
    Contributor

    We could defensively add a mounted check but it'd be really nice to either know we can't avoid it because of async something messing it up (I can't see anything that would) or that we should remove it when we figure out what the real bug is.

  8. added
    P2Important issues not at the top of the work list
    and removed
    P1High-priority issues at the top of the work list
    on Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: imagesLoading, displaying, rendering imagesa: null-safetySupport for Dart's null safety featurec: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowcustomer: money (g3)frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions