Audio Fails Half The Time After App Resumes

When testing my app on device, I noticed it would it appeared to function correctly and work well. But if the device ( iPhone 6Plus and IPad2 ) ‘suspended’ app, when I tap home button or whatever to resume the app, the app still functions as it should, except absolutely no audio plays.  If I then press home button to suspend it again, and then resume the app again, the audio restores and plays.  I spent 3 days going over my app and all it’s functions, testing the timing of various audio calls, figuring that some line of code or timer in my app was causing this problem.

I did not want to trouble the forum community with this question if I thought it was something I had wrong in my code, so I decide to just test with a simple and basic app to see if same issue occurs, and it does.  It just occurs inconsistently … not every time it goes into suspend and resumes. Wether it is 6 seconds or 10 seconds or 10 minutes later (I have tested repeatedly) it does it fail … but it does only sometimes.  At times it seemed like there was a pattern, that is every other time I suspended and then resumed say 7-8 seconds later - it failed, and every other time it played audio.  But, then I had 3,4, or 5 successful times where the audio played, before the next resume failed.

Maybe this was discussed at some time in the past on the forums.  I am sorry if I missed it, I did search internet and the forums and only saw an audio issue after resume ‘years’ ago pertaining to Android, and the thought I believe then was something with Android OS… but I am testing so far just on apple - 6Plus and Ipad2.

You might say, pause all timers on suspend and resume them on system resume… good idea.  I did that as you can see in my second simple code example below… and it also ‘failed audio completely’, and that means even the button click that is not on a timer fails to play.  It doesn’t happen all the time, not even every other time like I thought the pattern showed; but it does happen.  However, it does seem to happen less often with the pause and resume timer code in place.  I think I went about 4 times in a row when it did not fail, then on the next it did.

SDK 2017.3163

IOS on iphone  11.2

Anyone have experience with this.  Is there a work around.  I do not see anything in this simple test code, that should create this issue.  Here is the simple test code:

local sound1 = audio.loadSound("Audio/boom.wav") local function runSFX() audio.play(sound1) end timer.performWithDelay(3000, runSFX, -1)

Here is the test code with pause and resume of timers on suspend and resume of system

local widget = require("widget") local sfxTimer local sound1 = audio.loadSound("Audio/boom.wav") local click = audio.loadSound("Audio/click.mp3") local function runSFX() audio.play(sound1) end local function onButton(e) if e.phase == "ended" then audio.play(click) print("button pressed and released") end end local button = widget.newButton{ defaultFile = "Textures/bar.png", overFile = "Textures/bar\_dn.png", onEvent = onButton } button.x = 150 button.y = 150 local function onSystemEvent( event ) if (event.type == "applicationExit") then elseif (event.type == "applicationOpen") then elseif (event.type == "applicationResume") then sfxTimer.resume() elseif (event.type == "applicationSuspend") then sfxTimer.pause() end end sfxTimer = timer.performWithDelay(3000, runSFX, -1)

Thanks

Bob

Hey Bob, that’s an interesting problem that I’ve not heard of before from anyone. Since you have a test project, can you zip that up (make sure to include your config.lua and build.settings and the sound files) and use the “Report a bug” link at the top of the page?

Thanks

Rob

Rob,

Will do.

Thanks

Sorry I have to jump in here. I have developed a bigger game project an we discover the same problem: sometimes the sound is gone after a suspend/resume.

Any progress on this issue?

Does this appear on every iOS device?
We encountered this problem on an iPhone 6s plus but have not tested on other devices very intense.

Anything I can do to better investigate on this problem?

Rene,

Thanks for weighing in on this. I just got a response a few hours ago from corona support.  The tester said he was unable to reproduce error on a iPhone 6 Plus (iOS 11.2) … tester asked me if there was any chance I had device on mute. And I responded just a bit ago to the tester that I did not. 

I tested this test app on my 6 S plus and Ipad2.  But my actual app that I am ready to release (much larger then the simple test app I posted) failed on the 6 S plus and the iPad2; but I actually first noticed it on a cheap and old android HTC601  … I actually f irst discovered the issue  when I was testing on that android and I thought the issue might be with either the older operating software or the older device.

So it fails on at least 3 different devices.  I did the test app to strip the app down to the basic an least complex code I could think of, so as to eliminate anything with my code that could have been causing this. 

I will try to remember to update this post and/or contact you directly once I hopefully get a solution from support.

Thanks

Bob

Oh, I did not expect this issue happening on Android too?!

I remember that I once read of a case that one tried to plugin headphones when audio was gone and he had audio in headphone.
Maybe if you encounter the bug again you could try as well. I will tell our QA to test this too. Just clutching a straw …

Thank you in advance for sharing any insights. Of course I will let you know if we have any progress here, too.

Hey Bob, that’s an interesting problem that I’ve not heard of before from anyone. Since you have a test project, can you zip that up (make sure to include your config.lua and build.settings and the sound files) and use the “Report a bug” link at the top of the page?

Thanks

Rob

Rob,

Will do.

Thanks

Sorry I have to jump in here. I have developed a bigger game project an we discover the same problem: sometimes the sound is gone after a suspend/resume.

Any progress on this issue?

Does this appear on every iOS device?
We encountered this problem on an iPhone 6s plus but have not tested on other devices very intense.

Anything I can do to better investigate on this problem?

Rene,

Thanks for weighing in on this. I just got a response a few hours ago from corona support.  The tester said he was unable to reproduce error on a iPhone 6 Plus (iOS 11.2) … tester asked me if there was any chance I had device on mute. And I responded just a bit ago to the tester that I did not. 

I tested this test app on my 6 S plus and Ipad2.  But my actual app that I am ready to release (much larger then the simple test app I posted) failed on the 6 S plus and the iPad2; but I actually first noticed it on a cheap and old android HTC601  … I actually f irst discovered the issue  when I was testing on that android and I thought the issue might be with either the older operating software or the older device.

So it fails on at least 3 different devices.  I did the test app to strip the app down to the basic an least complex code I could think of, so as to eliminate anything with my code that could have been causing this. 

I will try to remember to update this post and/or contact you directly once I hopefully get a solution from support.

Thanks

Bob

Oh, I did not expect this issue happening on Android too?!

I remember that I once read of a case that one tried to plugin headphones when audio was gone and he had audio in headphone.
Maybe if you encounter the bug again you could try as well. I will tell our QA to test this too. Just clutching a straw …

Thank you in advance for sharing any insights. Of course I will let you know if we have any progress here, too.