Skip to content

[Bandcamp] Fix NetworkOnMainThreadException on rotate / back - #13955

Open
ngan-giang-phan wants to merge 6 commits into
TeamNewPipe:devfrom
ngan-giang-phan:bandcamp-back-crash
Open

ngan-giang-phan wants to merge 6 commits into
TeamNewPipe:devfrom
ngan-giang-phan:bandcamp-back-crash

Conversation

@ngan-giang-phan

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the size/medium PRs with less than 250 changed lines label Oct 24, 2026
@ngan-giang-phan ngan-giang-phan changed the title [Bandcamp] Fix Bandcamp NetworkOnMainThreadException on rotate / back [Bandcamp] Fix NetworkOnMainThreadException on rotate / back Oct 24, 2026
@ShareASmile ShareASmile added bug Issue is related to a bug GUI Issue is related to the graphical user interface Bandcamp Service, https://bandcamp.com/ labels Oct 24, 2026
@TobiGr

TobiGr commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Thank you for the contribution! Is it part of the yearly ANU assignement? I'll review this PR in the next few days.

@TobiGr
TobiGr self-requested a review October 25, 2026 17:29
@TobiGr TobiGr self-assigned this Oct 25, 2026
@sonarqubecloud

Copy link
Copy Markdown

@ngan-giang-phan

Copy link
Copy Markdown
Author

Is it part of the yearly ANU assignement?

Yes, it is. Thanks for taking the time to review it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bandcamp Service, https://bandcamp.com/ bug Issue is related to a bug GUI Issue is related to the graphical user interface size/medium PRs with less than 250 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants