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

Audio does not resume after it has been suspended by iOS (iPhone 5s & iOS 7.1) #65

Open
gelano opened this issue Apr 22, 2014 · 9 comments

Comments

@gelano
Copy link

gelano commented Apr 22, 2014

Environment: iOS 7.1, iPhone 5s

Based on the OALAudioTrack sample code and using either the bleeding edge or 2.2 version for iOS, audio output does not resume after audio is interrupted by either Siri, dictation (via keyboard), phone call, or alarm. I have also tried the last commit changes on OALAudioTrack.m which does not resolve this problem.

Reproducibility: 100% on iPhone 5s with iOS 7.1

Other environments tested:

  • iPhone 5 and iOS 7.0.2 - Not reproducible
  • iPhone 4s and iOS 7.0.4 - Not reproducible
  • iPhone 4s and iOS 7.1 - Not reproducible

The only output in the console window is as follows:
2014-04-21 21:11:13.684 {App Name Omitted}[8559:60b] !!! _NSLayoutTreeGetBaselineOffsetForGlyphAtIndex invalid glyph index 0

Note: Using OALSimpleAudio sample code generates an exception.

Let me know if I need to provide any additional information to help. Thanks.

@gelano
Copy link
Author

gelano commented Apr 24, 2014

I believe I figured this one out...

In OALSuspendHandler.m, setInterrupted:value method, there is a function call to objc_msgsend(). I assume this was used since the name of the receiving class/target and the selector are determined at runtime. Unfortunately, the parameter, in this case interruptLock, is always received as false on the receiving selector even if interruptLock was set to true.

Again, I don't see this happening on the other test phones I have, just on the iPhone 5s with 7.1 (and 7.1.1).

In order to workaround this problem, I changed my version of OALSuspendHandler.m setInterrupted:value. I replaced:

objc_msgSend(suspendStatusChangeTarget, suspendStatusChangeSelector, interruptLock);

with

void (*suspendStatusChange)(id, SEL, bool);
suspendStatusChange = (void (*)(id, SEL, bool))[suspendStatusChangeTarget methodForSelector:suspendStatusChangeSelector];
suspendStatusChange(suspendStatusChangeTarget, suspendStatusChangeSelector, interruptLock);

The same problem may exist with the use of objc_msgsend() function in the setManuallySuspended:value within the same class. I'm not a contributor, so if any of the active contributors to this project wants to verify my results and incorporate this change, feel free to do so.

Cheers!

besbes added a commit to mysugr/ObjectAL-for-iPhone that referenced this issue May 26, 2014
@picobots
Copy link

Hey @kstenerud, have you had an opportunity to look into this by chance? You and I were e-mailing about a very similar issue last month (Gmail thread titled "ObjectAL + iOS interruptions"), but we never did solve it. I'm wondering if the solution proposed above works?

@gelano, @besbes: Are you guys still successfully using this solution? Can it safely be merged into ObjectAL?

@besbes
Copy link
Contributor

besbes commented Jun 24, 2014

@picobots: yes, we're using this workaround. Didn't observe any problems with it so far.

@kstenerud
Copy link
Owner

Hi @picobots, could you make a PR with this fix? I'll push it to the main branch for everyone.

@picobots
Copy link

Sure, I definitely could. But it looks like @besbes already has a fork with the solution committed:
mysugr@711f93a

@besbes, maybe you could just submit a PR? Credit where credit is due :)

@besbes
Copy link
Contributor

besbes commented Jun 24, 2014

@picobots @kstenerud I created a PR with this fix. Thanks for the support!

@kstenerud
Copy link
Owner

Merged. Thanks!

@picobots
Copy link

picobots commented Jul 3, 2014

I just noticed another "disappearing sound effects" bug, this time on iOS 6 (on an iPad 2). It's pretty much the same as what's described here:

https://groups.google.com/d/msg/objectal-for-iphone/ubRWltp_i1Q/GR0FWSW6vi0J

Steps to reproduce:

  1. Open my app and play some sound effects with ObjectAL.
  2. Minimize my app.
  3. Open a different app with sound effects (e.g., a game—The Last Rocket seems to work well) and play it for a minute.
  4. Minimize the other app.
  5. Reopen my app.
  6. Sound effects don't play anymore :(

@kstenerud: The link above is a pretty old issue, did you ever solve that in the past? Is it possible that this new interruption bug fix reintroduced an old iOS 6 bug? Sub-question: Perhaps the old code should still be in place for iOS 6 and below, with this new code only for iOS 7+?

@besbes and @gelano: Can either of you confirm that you're also seeing disappearing sound effects on iOS 6 as described above?

@picobots
Copy link

picobots commented Jul 3, 2014

More information: Sound effects also seem to disappear on iOS 6 if the audio is interrupted (e.g., by a FaceTime call). I could've sworn this used to work with ObjectAL and iOS 6, didn't it? I'm wondering if this new iOS 7 fix just isn't "iOS 6 safe".

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

No branches or pull requests

4 participants