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

Convert PlayerHolder to Singleton; cleanup in VideoDetailFragment; Player/MainPlayer do not call onDestroy() directly #6566

Merged
merged 5 commits into from
Jul 14, 2021

Conversation

evermind-zz
Copy link
Contributor

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

  • PlayerHolder: convert to Singleton, handle context within, prevent ServiceConnection leak
  • VideoDetailFragment: use viewBinding correctly
  • VideoDetailFragment: remove duplicated code for toggle Fullscreen
  • VideoDetailFragment: move null checks for player and playerService to helper methods
  • Player/MainPlayer: service.onDestroy() should only be called from the system and not manually

Fixes the following issue(s)

APK testing

On the website the APK can be found by going to the "Checks" tab below the title and then on "artifacts" on the right.

Due diligence

…ually

instead use service.stopService() which inturn calls stopSelf() and
triggers hopefully onDestroy() to be called. Eventually we have to make
sure that all ServiceConnections are closed to successfully stop the service
now!

Cleanup within stopService() and not only onDestroy()

So we make sure that all listeners can react to onServiceStopped()
and close their ServiceConnections. Afterwards the android framework
is ready to stop the Service.
@evermind-zz evermind-zz changed the title Various fixes for upstream Convert PlayerHolder to Singleton; cleanup in VideoDetailFragment; Player/MainPlayer do not call onDestroy() directly Jun 24, 2021
@AudricV AudricV added the codequality Improvements to the codebase to improve the code quality label Jun 24, 2021
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Looks mostly good. Thank you!
I also tested a little bit on API 29 and the player worked flawlessly; I read the logcat logs but found no strage errors, not even on player closing, so I think this changes are ok.

- code is easier to read
- duplication of code reduced
…iceConnection leak

- bugfix: have ServiceConnection created only once!

- select the context within the PlayerHolder to start, stop, bind or unbind the service
  -> we have to make sure the Service is started AND stopped within the same context
  -> so let PlayerHolder be the one to select the context

- remove removeListener() and replace the call with setListener(null)
- Compatibility: use ContextCompat.startForegroundService instead of startService()
@evermind-zz
Copy link
Contributor Author

I've merged the changes and updated the pull request

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

I also tested on API 19, everything works fine, thank you :-)

@TobiGr TobiGr merged commit 14dab85 into TeamNewPipe:dev Jul 14, 2021
@evermind-zz evermind-zz deleted the various-fixes-for-upstream branch July 26, 2021 11:33
This was referenced Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codequality Improvements to the codebase to improve the code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants