Skip to content

[SideSheetBehavior] NullPointerException in setState > runAfterLayout #4975

@eugenegff

Description

@eugenegff

Description: NullPointerException in SideSheetBehavior setState > runAfterLayout, happens when viewRef was nullified as part of SideSheetBehavior.onDetachedFromLayoutParams() and only then accessed by setState() > runAfterLayout lambda. Similar nearby checks outside of lambda are not enough, as all of them are executed immediately, and access in lambda is done later, after layout.

Fix for the issue is in #4974

Screenshot of the problematic SideSheetBehavior.setState() code is attached below, line where viewRef is accessed without viewRef != null check is highlighted, viewRef was not null initially, during setState() call, but then SideSheetBehavior was detached from view, and only then view was layout and lambda with highlighted line of the already detached SideSheetBehavior was run

Image

Android API version: 30-36

Material Library version: 1.13, but actually any

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions