Skip to content

fix null-check crash in offline mode sheet toggle#8753

Merged
krushnarout merged 1 commit into
mainfrom
fix/offline-mode-sheet-setstate-crash
Jul 2, 2026
Merged

fix null-check crash in offline mode sheet toggle#8753
krushnarout merged 1 commit into
mainfrom
fix/offline-mode-sheet-setstate-crash

Conversation

@krushnarout

@krushnarout krushnarout commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Fixes a Crashlytics-reported fatal crash (Null check operator used on a null value in State.setState) originating from _ProfilePageState._showOfflineModeSheet.
  • setEnabled is async; after await captureProvider.setBatchMode(value) resolves, the offline-mode bottom sheet or the profile page itself may already be disposed (user closed the sheet or navigated away), so calling setSheetState/setState hit a disposed State.
  • Guards both calls with mounted checks (sheetContext.mounted for the sheet's StatefulBuilder, mounted for the outer _ProfilePageState).

Crashlytics issue: https://console.firebase.google.com/u/0/project/based-hardware/crashlytics/app/android:com.friend.ios/issues/0685c58070c96ed5989ef2091f644ff4?time=7d&types=crash

Test plan

  • Open Profile → Offline Mode sheet, toggle the switch, and immediately dismiss the sheet/navigate away before the async setBatchMode completes — confirm no crash and no unhandled exception in logs.
  • Toggle the switch normally (staying on the sheet) and confirm state updates as expected.

🤖 Generated with Claude Code

Review in cubic

Guard setState/setSheetState with mounted checks after the async
batchMode update, since the profile page or sheet may already be
disposed by the time the await resolves.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM — the fix is correct. Guarding setSheetState/setState with mounted checks after the await is the right pattern for this disposed-state crash. Test plan covers both the race and the normal path.

One heads-up: _showBackgroundModeSheet (~line 249) has the same unguarded setSheetState(() {}); setState(() {}); after await captureProvider.setBackgroundModeEnabled(value). It's the same latent crash signature — worth guarding in a follow-up when convenient.

Reviewed by the Omi PR maintainer automation (AI).

@krushnarout krushnarout merged commit 4ce839b into main Jul 2, 2026
3 checks passed
@krushnarout krushnarout deleted the fix/offline-mode-sheet-setstate-crash branch July 2, 2026 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants