Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempt to fix frequent MiniPlayerFragment ANRs seen in production (#96)
For background on the issue, and why this change may help, see androidx/media#890. I had hoped that upgrading the Media3 library version back in #92 would completely solve the problems we had been seeing in production. While it did help in some ways, by eliminating `ForegroundServiceDidNotStartInTimeException`s (see androidx/media#167), it also seems to have morphed a lot of problems into a new form, namely App Not Responding (ANR) problems that arise in `MiniPlayerFragment`. The basic idea here is to reduce the rate at which we create and release `MediaController`s in `MiniPlayerFragment`, by moving the creation and releasing to fragment lifecycle callbacks that are invoked less frequently than `onResume()` and `onPause()`. My hypothesis is that rapid creation and releasing of `MediaController`s results in some kind of race condition that is very hard to reproduce locally but will occur in production with enough use of the app. It's not completely clear that this PR will definitely solve the problems we're seeing in production, but it seems like a worthwhile experiment to try. Other than potentially decreasing the rate of ANRs, it should not have any other noticeable effects on the behavior of the app.
- Loading branch information