Skip to content

Fix NullPointerException in enqueue actions by using Application Context#13385

Merged
TobiGr merged 1 commit intoTeamNewPipe:devfrom
arjun1194:fix/use-application-context-for-enqueue
Mar 29, 2026
Merged

Fix NullPointerException in enqueue actions by using Application Context#13385
TobiGr merged 1 commit intoTeamNewPipe:devfrom
arjun1194:fix/use-application-context-for-enqueue

Conversation

@arjun1194
Copy link
Copy Markdown
Contributor

@arjun1194 arjun1194 commented Mar 28, 2026

What is it?

  • Bugfix (user facing)
  • Feature (user facing) ⚠️ Your PR must target the refactor branch
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • In StreamDialogDefaultEntry, the ENQUEUE, ENQUEUE_NEXT, START_HERE_ON_BACKGROUND, and START_HERE_ON_POPUP entries used fragment.getContext() inside the async callback of fetchItemInfoIfSparse(). Since the callback runs asynchronously, the fragment may have already been detached (e.g., due to entering fullscreen or rotating the device), causing getContext() to return null.
  • Replaced with fragment.requireContext().getApplicationContext() captured before the async call, while the fragment is still attached. The Application context is lifecycle-safe and remains valid regardless of configuration changes.

Before/After Screenshots/Screen Record

N/A — no UI changes, this is a crash fix only.

Fixes the following issue(s)

APK 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/large PRs with less than 750 changed lines label Mar 28, 2026
Use getApplicationContext() instead of getContext() in ENQUEUE,
ENQUEUE_NEXT, START_HERE_ON_BACKGROUND, and START_HERE_ON_POPUP
entries to prevent NullPointerException when the fragment's activity
context becomes null during configuration changes (e.g. device rotation).

The fragment context can become null when the activity is destroyed
during rotation, but the async callback from fetchItemInfoIfSparse
still holds a reference to the now-detached fragment. Using
Application context ensures a stable, non-null context throughout
the async operation lifecycle.
@arjun1194 arjun1194 force-pushed the fix/use-application-context-for-enqueue branch from 5f55d7d to 07a2ab2 Compare March 28, 2026 08:55
@github-actions github-actions Bot added size/small PRs with less than 50 changed lines and removed size/large PRs with less than 750 changed lines labels Mar 28, 2026
@TobiGr TobiGr added bug Issue is related to a bug template missing The bug/feature template is missing (e.g. the used app does not support issue templates) labels Mar 28, 2026
@arjun1194 arjun1194 mentioned this pull request Mar 28, 2026
7 tasks
@TobiGr TobiGr added the template ignored The user didn't follow the template/instructions (or removed them) label Mar 28, 2026
@TobiGr
Copy link
Copy Markdown
Contributor

TobiGr commented Mar 28, 2026

Hello and thank you for the PR. Please use our PR template and read our AI policy carefully. Please link an issue with a stacktrace. The changes in this PR will be superseeded by #12032

@arjun1194
Copy link
Copy Markdown
Contributor Author

The changes in this PR will be superseeded by #12032

what do you mean ? is my PR going to be closed because some PR already fixes the issue ? @TobiGr

@arjun1194
Copy link
Copy Markdown
Contributor Author

i have updated the pr description @TobiGr

Copy link
Copy Markdown
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

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

thank you

@TobiGr TobiGr merged commit 50e8189 into TeamNewPipe:dev Mar 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue is related to a bug size/small PRs with less than 50 changed lines template ignored The user didn't follow the template/instructions (or removed them) template missing The bug/feature template is missing (e.g. the used app does not support issue templates)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Player Crashes when queuing

2 participants