Skip to content

Avoid a possible race condition with the player delegate#893

Merged
sbooth merged 11 commits intomainfrom
strong-delegate
Apr 9, 2026
Merged

Avoid a possible race condition with the player delegate#893
sbooth merged 11 commits intomainfrom
strong-delegate

Conversation

@sbooth
Copy link
Copy Markdown
Owner

@sbooth sbooth commented Mar 22, 2026

No description provided.

@sbooth sbooth marked this pull request as ready for review March 27, 2026 16:08
Copilot AI review requested due to automatic review settings March 27, 2026 16:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces the chance of a weak SFBAudioPlayer.delegate being deallocated between respondsToSelector: checks and the subsequent delegate message sends by snapshotting the delegate into a strong local before invoking callbacks.

Changes:

  • Snapshot player_.delegate (and player.delegate inside blocks) into a strong local variable before checking selectors and calling delegate methods.
  • Apply the snapshot pattern across playback state, now-playing, decoding, rendering, and interruption/configuration-change notifications.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/CSFBAudioEngine/Player/AudioPlayer.mm Outdated
Comment thread Sources/CSFBAudioEngine/Player/AudioPlayer.mm Outdated
Comment thread Sources/CSFBAudioEngine/Player/AudioPlayer.mm Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sbooth sbooth merged commit 21cb49e into main Apr 9, 2026
6 checks passed
@sbooth sbooth deleted the strong-delegate branch April 9, 2026 22:54
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.

2 participants