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

Remove static MediaButtonReceiver in AndroidManifest for v3.2 #1888

Merged
merged 2 commits into from
Feb 10, 2023

Conversation

martinmidtsund
Copy link
Contributor

@martinmidtsund martinmidtsund commented Jan 25, 2023

The first commit removes the static MediaButtonReceiver which is causing a lot of RemoteServiceExceptions, and a group of other related exceptions, most of them mentioned in this issue. This change made all of the related errors go away in our production environment, and has been running there for almost a month now. @elliotdickison has also reported the same.

See https://developer.android.com/guide/topics/media-apps/mediabuttons#summary where they say you need the static MediaButtonReceiver for pre-lollipop, but later versions don't need it.

As seen here a service can also receive media button actions: A service can receive a key event by including an intent filter that handles ACTION_MEDIA_BUTTON which is already registered in the manifest, and it seems to work just fine. We have verified with a connected bluetooth headset that skip, play and pause is still working when originating from the headset. It would be great if you could test the PR and verify it with other devices as well.

The last commit exporting the MusicService and setting foregroundServiceType is not tested in production yet, but should be set as I gather from this page

Sorry for the wall of text. Please advise if anything should be changed.

@martinmidtsund martinmidtsund changed the title V3.2 Remove static MediaButtonReceiver in AndroidManifest for v3.2 Jan 25, 2023
Copy link
Contributor

@mmmoussa mmmoussa left a comment

Choose a reason for hiding this comment

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

We have been using this change, but with android:exported left unchanged (ie. false), in production with a large number of users. I can confirm that it has significantly reduced our crash rate by resolving #1676 and #1874. However, we are still encountering #1666 and #1812.

@martinmidtsund
Copy link
Contributor Author

@mmmoussa Great to hear! My guess, without having been able to test it yet, is that the last commit hopefully alleviates some of the notAllowed errors.

@martinmidtsund
Copy link
Contributor Author

As you can see here if we removed the exported-attribute the default would be true as long as we an intent filter present, without the intent filter the default would be false.

biomancer added a commit to perushevandkhmelev-agency/react-native-track-player that referenced this pull request Feb 1, 2023
@mmmoussa
Copy link
Contributor

mmmoussa commented Feb 6, 2023

We have been running with all of the changes in this PR (including exported as true) and I can confirm that #1666 and #1812 are not fixed, though this is still worth merging as it fixes other issues as mentioned previously.

@bradfloodx
Copy link
Collaborator

Yep same here. Deployed this change to production, still getting crash reports on new versions for #1666 and #1812 :(

@martinmidtsund
Copy link
Contributor Author

@mmmoussa @bradleyflood Thanks for testing!

Perhaps @jspizziri or @dcvz could take a look? I really think this should go into the main-branch as well as this 3.2 branch, but it's a good place to start. :)

@dcvz
Copy link
Contributor

dcvz commented Feb 6, 2023

@mmmoussa @bradleyflood Thanks for testing!

Perhaps @jspizziri or @dcvz could take a look? I really think this should go into the main-branch as well as this 3.2 branch, but it's a good place to start. :)

This one is on our radar! We’ll likely cherry pick after merge and make one more release of 3.2 — we’re just waiting until one of us gets a chance to test it with a few devices.

@dcvz
Copy link
Contributor

dcvz commented Feb 10, 2023

Alright merging this in @martinmidtsund and cherry picking to 4.0.0 nightlies. We'll keep an eye out for any unintended consequences.

@dcvz dcvz merged commit 2522705 into doublesymmetry:v3.2 Feb 10, 2023
shawna-donnelly pushed a commit to heistdotcom/react-native-track-player that referenced this pull request Apr 4, 2023
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.

5 participants