Skip to content

Conversation

NightBlaze
Copy link
Contributor

Fix iOS crash on startup due to inactive audio session

Copilot

This comment was marked as outdated.

@roderickvd
Copy link
Member

@NightBlaze thanks for the fix! Could you let me know if you agree with that Copilot review?

@NightBlaze NightBlaze requested a review from roderickvd July 31, 2025 07:44
@roderickvd roderickvd requested a review from Copilot August 3, 2025 18:26
Copilot

This comment was marked as outdated.

@roderickvd
Copy link
Member

@NightBlaze thanks for updating and resuscitating this PR 😄

As I said, I'm no iOS developer and so like to depend on Copilot for a review and then see if it makes sense. It's offering some more comments after your latest update. If you would look into those?

Thanks for getting this right 💪

NightBlaze and others added 2 commits August 4, 2025 08:56
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@NightBlaze
Copy link
Contributor Author

@NightBlaze thanks for updating and resuscitating this PR 😄

As I said, I'm no iOS developer and so like to depend on Copilot for a review and then see if it makes sense. It's offering some more comments after your latest update. If you would look into those?

Thanks for getting this right 💪

@roderickvd Yes, I agree with the comments. I haven't written in Objective-C for a while, so I've forgotten some of the details :) I've updated the PR.

@roderickvd roderickvd requested a review from Copilot August 4, 2025 20:53
Copy link

@Copilot 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 fixes an iOS crash on startup by properly activating the audio session after setting its category. The fix adds explicit audio session activation with proper error handling to prevent crashes when the app starts with an inactive audio session.

Key Changes

  • Add audio session activation after setting the category
  • Improve error handling with separate error variables for category and activation operations
  • Update error logging to provide more specific error information
Comments suppressed due to low confidence (2)

examples/ios-feedback/ios-src/AppDelegate.m:33

  • [nitpick] The variable name 'isSetCategorySuccess' is verbose and inconsistent with iOS naming conventions. Consider using 'categorySuccess' or 'setCategorySuccess' to follow typical Objective-C naming patterns.
    BOOL isSetCategorySuccess = [session setCategory:AVAudioSessionCategoryPlayAndRecord

examples/ios-feedback/ios-src/AppDelegate.m:38

  • [nitpick] The variable name 'isActivateSuccess' is verbose and inconsistent with iOS naming conventions. Consider using 'activateSuccess' or 'setActiveSuccess' to follow typical Objective-C naming patterns.
        BOOL isActivateSuccess = [session setActive:YES error:&activateError];

Copy link
Member

@roderickvd roderickvd left a comment

Choose a reason for hiding this comment

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

Cool, thanks. If you could top it off with a changelog entry? Good to merge after.

Copilot came up with two final nitpicks regarding variable naming, if you want to take those into account, at your option.

@NightBlaze
Copy link
Contributor Author

Updated the changelog.

This time I don't agree with Copilot because Objective-C is very verbose and by convention bool flags should start from is, should or have/has.

Thanks for guided me through the PR!

@NightBlaze NightBlaze requested a review from roderickvd August 6, 2025 07:00
Copy link
Member

@roderickvd roderickvd left a comment

Choose a reason for hiding this comment

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

Thanks a lot for doing the iterations and getting the example exactly right. Very valuable for users.

@roderickvd roderickvd merged commit fb27946 into RustAudio:master Aug 8, 2025
15 checks passed
roderickvd pushed a commit to roderickvd/cpal that referenced this pull request Aug 30, 2025
roderickvd pushed a commit to roderickvd/cpal that referenced this pull request Aug 30, 2025
roderickvd pushed a commit to roderickvd/cpal that referenced this pull request Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants