Skip to content

bugfix-library - Fix mobile crash on library browse scroll - #1072

Merged
RadicalMuffinMan merged 2 commits into
Moonfin-Client:mainfrom
mattsigal:bugfix/debug-mobile-browse-crash
Aug 7, 2026
Merged

bugfix-library - Fix mobile crash on library browse scroll#1072
RadicalMuffinMan merged 2 commits into
Moonfin-Client:mainfrom
mattsigal:bugfix/debug-mobile-browse-crash

Conversation

@mattsigal

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

Fix an unhandled crash on mobile clients when opening a library and scrolling in vertical/horizontal mode past the initial pull. The crash was caused by accessing disposed FocusNodes in QuickReturnWrapper during initial library page load reset, alongside missing bounds checks in SliverChildBuilderDelegate. It seems isolated to mobile.

Related Issues

Link related issues or tickets separated by commas.

  • Closes #
  • Fixes #
  • Related to #

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • UI/UX update
  • Documentation update
  • Build/CI change
  • Other (describe):

Changes Made

List the key changes included in this PR.

  • library_browse_screen.dart: Checked _vm.items.isNotEmpty before passing getGridItemFocusNode(0) to QuickReturnWrapper, preventing QuickReturnWrapper from holding a reference to a FocusNode disposed by cleanupGridFocusNodes(0).
  • library_browse_screen.dart: Added bounds checks if (index < 0 || index >= itemsToDisplay.length) return null; inside SliverChildBuilderDelegate for vertical and horizontal grid layouts. Added _scrollController.hasClients guards in _nearGridEnd and horizontal scroll listener.
  • quick_return_wrapper.dart: Added canRequestFocus check on topFocusNode before requesting focus in _returnToStart().

Platform

  • Android
  • iOS
  • tvOS
  • Web
  • macOS
  • Windows
  • Linux
  • All / Shared code

Testing

Describe how this change was tested.

  • Tested on emulator / simulator
  • Tested on physical device
  • Manual testing completed - Tested on Pixel 10 Pro (also where the bug was found)
  • Not tested (explain why):

Test Steps

  1. Launch Moonfin on an Android mobile device (or compact screen mode).
  2. Open any library (e.g., Movies, TV Shows) without applying Group By filters first.
  3. Verify the library loads smoothly on initial page load in both vertical and horizontal scroll orientation without crashing.
  4. Scroll to the bottom of the grid and verify infinite scroll loads additional pages smoothly.

Screenshots (if applicable)

Include screenshots or recordings for UI changes.

Checklist

  • Code builds successfully
  • Code follows project style and conventions
  • No unnecessary commented-out code
  • No new warnings introduced

- Check for active items before passing getGridItemFocusNode(0) as topFocusNode in QuickReturnWrapper.
- Add canRequestFocus check on topFocusNode in QuickReturnWrapper before requesting focus.
- Add index bounds checking inside SliverChildBuilderDelegate in vertical and horizontal grid builders.
- Add _scrollController.hasClients checks in _nearGridEnd and horizontal grid pointer scroll listeners.
@RadicalMuffinMan
RadicalMuffinMan merged commit dc21120 into Moonfin-Client:main Aug 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants