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

Upgrade android media library #92

Merged
merged 2 commits into from
Nov 21, 2023
Merged

Upgrade android media library #92

merged 2 commits into from
Nov 21, 2023

Conversation

bb4242
Copy link
Collaborator

@bb4242 bb4242 commented Nov 17, 2023

A new version, 1.2.0, of the android media library was just released. This release includes several fixes that are relevant to androidx/media#167, which seems to be the root cause of some issues we've been seeing in production, particularly on Samsung devices. Among many other changes, the release notes for 1.2.0 say this: "Use only android.media.session.MediaSession.setMediaButtonBroadcastReceiver() above API 31 to avoid problems with deprecated API on Samsung devices (androidx/media#167)." I'm hopeful that upgrading to 1.2.0 will resolve our issues in production. We'll be able to monitor the impact of the upgrade using crashlytics (see #91).

Upgrading to 1.2.0 also required upgrading our targetSdk to version 34. This was straightforward, it just required adding one more permission that is now required by Android for playing media in a foreground service. I also updated the com.google.android.material library for good measure as it was slightly out of date; this shouldn't have any noticeable impact.

This also requires updating our target SDK version to 34.

Hopefully this will resolve some of the crashes we've been seeing in
production, particularly on Samsung devices.
@bb4242 bb4242 changed the title Media 1.2.0 Upgrade android media library Nov 17, 2023
Copy link
Contributor

@intermarc intermarc left a comment

Choose a reason for hiding this comment

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

That is a very promising update @bb4242. It really does sound like the new media library will address the issues you have noticed. I don't have any experience with the build system and dependency handling for android apps, so all I can really say is that none of the changes look obviously broken to me!

I've been testing media-1.2.0 on my phone for a few days and have not had any issues at all (neither building and installing nor in use). So it's all green lights from me 👍

@bb4242 bb4242 merged commit b0803d2 into master Nov 21, 2023
1 check passed
bb4242 added a commit that referenced this pull request Dec 19, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants