NewPipe icon indicating copy to clipboard operation
NewPipe copied to clipboard

Fix crash in MediaSessionPlayerUi while destroying player

Open Stypox opened this issue 1 year ago • 1 comments

What is it?

  • [x] 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)

  • Fixes #11029

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

Stypox avatar Jul 11 '24 07:07 Stypox