Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in MediaSessionPlayerUi while destroying player #11261

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

Stypox
Copy link
Member

@Stypox Stypox commented Jul 11, 2024

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

This PR simply fixes the NullPointerException reported in #11029 by adding a null check and by adding @Nullable to the involved variables.

Note that the crash happened because in Player::destroyPlayer(), first PlayerUi::destroyPlayer is called on every UI, and afterwards simpleExoPlayer.removeListener(this) causes a call to onEvents() which in turn calls onMetadataChanged(info) on every UI in an unexpected moment (i.e. after PlayerUi::destroyPlayer()), causing the crash inside MediaSessionPlayerUi.onMetadataChanged().

I can consistently reproduce the crash in 0.27.0, while with this fix the crash does not happen anymore.

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/small PRs with less than 50 changed lines label Jul 11, 2024
@Stypox Stypox changed the base branch from dev to master July 11, 2024 07:40
@Stypox Stypox added ASAP Issue needs to be fixed as soon as possible player Issues related to any player (main, popup and background) labels Jul 11, 2024
Copy link

sonarcloud bot commented Jul 11, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASAP Issue needs to be fixed as soon as possible player Issues related to any player (main, popup and background) size/small PRs with less than 50 changed lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when player service is being stopped in some cases (NullPointerException)
2 participants