Skip to content

Fix Bandcamp NetworkOnMainThreadException on rotate / back (#11183) - #1

Closed
ngan-giang-phan wants to merge 5 commits into
devfrom
bandcamp-back-crash
Closed

ngan-giang-phan wants to merge 5 commits into
devfrom
bandcamp-back-crash

Conversation

@ngan-giang-phan

@ngan-giang-phan ngan-giang-phan commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

Fixes NetworkOnMainThreadException crash when rotating on a Bandcamp artist page, or when pressing system back from an album to the artist page. This is because handleResult() calls fromQuery() which makes a network request on main thread.

  • Added a lightweightTabHandler field to hold the replacement link handler, so it can be built on a background thread and passed to the main thread
  • Moved the existing logic in handleResult to a createLightweightTabHandler helper, to be called on the background thread
  • handleResult no longer calls fromQuery and swaps in the prepared handler
  • loadResult makes sure network requests are called on the background thread via doOnSuccess

Before/After Screenshots/Screen Record

Fixes the following issue(s)

Testing/QA

Devices
  • Tested on Android 13 (API 33) emulator
Steps for testing
  • Switch service to Bandcamp (service list -> Bandcamp)
  • Search up any artist on Bandcamp
  • Click on the artist page
  • Rotate the screen
  • Click on any album
  • Click on system back (at the bottom of the screen on Android devices) or swipe from the left edge
  • Verify that a crash didn't happen and the app still runs normally
APK for testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

@ngan-giang-phan ngan-giang-phan added the bug Something isn't working label Oct 21, 2026

@L1ly-Hou L1ly-Hou 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.

The fix looks good to me, I tested the APK on my emulator Android 13 (API 33, x86_64) without reproducing the original crash.

@alyshaizzati alyshaizzati 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.

Tested on an Android 15.0 (API 35) emulator.
Screen rotation and back navigation on Bandcamp work smoothly with no crashes or NetworkOnMainThreadException.

@ngan-giang-phan

Copy link
Copy Markdown
Owner Author

Opened upstream as TeamNewPipe#13955

@ngan-giang-phan ngan-giang-phan self-assigned this Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size/medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bandcamp] NetworkOnMainThreadException when rotating screen on artist/channel page

3 participants