Skip to content

#5886-Prevent Crash on Airplaying Audio Attachment #6058

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MarlowBrown
Copy link
Contributor

@MarlowBrown MarlowBrown commented May 26, 2025

Contributor checklist

  • My commits are rebased on the latest main branch
  • My commits are in nice logical chunks
  • My contribution is fully baked and is ready to be merged as is
  • I have tested my contribution on these devices:
  • iPhone 12, iOS 18.4.1

Description

This PR fixes #5886 by preventing AudioPlayers AVPlayer from externally playing. Weirdly (this will be explained later) this doesn't prevent audio from from being airplayed, but it prevents the dataRequests requested data length from being bigger than a UInt32, which was causing this crash to happen. I tested this by airplaying Spotify from my iPhone 12 to my Mac Mini and playing an audio attachment.

My hypothesis:

While working on this bug, I noticed that in the AudioPlayer class, we are using the AVPlayer class instead of the AVAudioPlayer class. I think the root cause of what is causing this bug to happen is that when we switch to using AirPlay, the system sees that the ResourceLoadingRequest is coming from an AVPlayer, something that is designed to play both video and audio, and then subsequently requests too much space for video content, something that will never come as were using only audio in our AVAssets. By disallowing external playback, we prevent any video content from being played outside the app (even though we don't have any) and subsequently the space for video content never gets allocated. I think by switching the AudioPlayers AVPlayer to AVAudioPlayer will solve this problem.

…rplay. This doesnt actually prevent playback over airplay, but it prevents the resource loading length from being much bigger than a UInt32 max value

(cherry picked from commit c46d9c607273049991f9a5357d0cd7470ec8cc06)
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.

1 participant