Bug 273041 - REGRESSION (iOS 17.5 beta): Memory leak with audio sprites
Summary: REGRESSION (iOS 17.5 beta): Memory leak with audio sprites
Status: RESOLVED DUPLICATE of bug 272568
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: Safari 17
Hardware: iPhone / iPad iOS 17
: P1 Blocker
Assignee: Nobody
URL: https://www.macguffinandshemp.com/iOS...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2024-04-21 06:32 PDT by Matthew Hutchinson
Modified: 2024-07-01 11:09 PDT (History)
9 users (show)

See Also:


Attachments
memory profile iOS 17.5 tab crashes and resets (235.76 KB, image/png)
2024-04-21 06:32 PDT, Matthew Hutchinson
no flags Details
memory profile iOS 17.4.1 - this does not result in the tab resetting (112.98 KB, image/png)
2024-04-21 06:43 PDT, Matthew Hutchinson
no flags Details
comparison of memory usage in iOS17.4.1 vs iOS17.5 (291.76 KB, image/png)
2024-04-21 08:23 PDT, Matthew Hutchinson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Hutchinson 2024-04-21 06:32:50 PDT
Created attachment 471030 [details]
memory profile iOS 17.5 tab crashes and resets

I have noticed that audio sprites when played are not released for garbage collection and result in the browser tab resetting. This is only happening in iOS 17.5 beta. All previous iOS release did not have this issue.

This issue can be seen here:

https://www.macguffinandshemp.com/iOS17test/

if you open this page in chrome or safari on iOS17.5 beta and click on the button labeled "audio sprite loop" you can see the memory rapidly increase and resulting in the browser tab resetting.

This issue is also happening using howlerjs and this demo has been created:

https://rayji0428.github.io/demo/howler/index.html

(from this howler bug report https://github.com/goldfire/howler.js/issues/1714)
Comment 1 Matthew Hutchinson 2024-04-21 06:43:48 PDT
Created attachment 471031 [details]
memory profile iOS 17.4.1 - this does not result in the tab resetting

This is the same page running on iOS17.4.1 As you can see the memory stays fairly flat.
Comment 2 Matthew Hutchinson 2024-04-21 08:22:19 PDT
Updated https://www.macguffinandshemp.com/iOS17test/ to generate audio based on:

https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/createBufferSource

If you start a "white noise loop" you can see from the attachment that after 60 seconds

iOS 17.4.1 memory = 199.82Mb
iOS 17.5 memory = 496Mb
Comment 3 Matthew Hutchinson 2024-04-21 08:23:44 PDT
Created attachment 471032 [details]
comparison of memory usage in iOS17.4.1 vs iOS17.5
Comment 4 Matthew Hutchinson 2024-04-22 06:22:57 PDT
This issue effects both Safari and Chrome on iOS 17.5
Comment 5 Ahmad Saleem 2024-04-22 07:48:43 PDT
Test crashing (from GitHub) - https://rayji0428.github.io/demo/cocos/index.html

^ haven't test myself.

NOTE - Please mute or reduce volume - it is not pleasing sound at all.
Comment 6 Chris Dumez 2024-04-22 08:55:14 PDT
I suspect I fixed very recently in Bug 272568.
Comment 7 Radar WebKit Bug Importer 2024-04-22 08:56:45 PDT
<rdar://problem/126863753>
Comment 8 RayJi 2024-04-22 09:49:30 PDT
(In reply to Ahmad Saleem from comment #5)
> Test crashing (from GitHub) -
> https://rayji0428.github.io/demo/cocos/index.html
> 
> ^ haven't test myself.
> 
> NOTE - Please mute or reduce volume - it is not pleasing sound at all.

Please use this one to test. Sorry about the volume, just trying to make it crash sooner...
https://rayji0428.github.io/demo/howler/index.html
Comment 9 Chris Dumez 2024-04-22 13:33:41 PDT
(In reply to RayJi from comment #8)
> (In reply to Ahmad Saleem from comment #5)
> > Test crashing (from GitHub) -
> > https://rayji0428.github.io/demo/cocos/index.html
> > 
> > ^ haven't test myself.
> > 
> > NOTE - Please mute or reduce volume - it is not pleasing sound at all.
> 
> Please use this one to test. Sorry about the volume, just trying to make it
> crash sooner...
> https://rayji0428.github.io/demo/howler/index.html

Thanks for the test case. I have confirmed that the jetsam reproduces before the fix for Bug 272568 but not after. This is a dupe. This issue should go away in a later build.

*** This bug has been marked as a duplicate of bug 272568 ***
Comment 10 Chris Dumez 2024-04-22 13:38:24 PDT
(In reply to Chris Dumez from comment #9)
> (In reply to RayJi from comment #8)
> > (In reply to Ahmad Saleem from comment #5)
> > > Test crashing (from GitHub) -
> > > https://rayji0428.github.io/demo/cocos/index.html
> > > 
> > > ^ haven't test myself.
> > > 
> > > NOTE - Please mute or reduce volume - it is not pleasing sound at all.
> > 
> > Please use this one to test. Sorry about the volume, just trying to make it
> > crash sooner...
> > https://rayji0428.github.io/demo/howler/index.html
> 
> Thanks for the test case. I have confirmed that the jetsam reproduces before
> the fix for Bug 272568 but not after. This is a dupe. This issue should go
> away in a later build.
> 
> *** This bug has been marked as a duplicate of bug 272568 ***

This was indeed a regression in iOS 17.5 beta and we reverted the patch that caused it.
Comment 11 Matthew Hutchinson 2024-04-22 13:41:43 PDT
Does this mean that the issue will not occur when iOS17.5 is releases officially?

Thanks for the info
Matt
Comment 12 Alexey Proskuryakov 2024-04-22 14:05:19 PDT
That's the plan!
Comment 13 Matthew Hutchinson 2024-04-23 11:32:10 PDT
Can confirm this fixed in 17.5 beta 3 - thanks all
Comment 14 Matthew Windwer 2024-06-30 13:05:28 PDT
Hi all,

This issue is back on iOS 17.6 beta. I reproduced in Safari on my iPad Mini 5th gen by visiting https://www.macguffinandshemp.com/iOS17test/ (thank you for that!). Press "audio sprite loop." It will crash Safari sooner or later. It does not crash iOS 17.5.1. I'm pretty sure this is the same issue I reported last week - bug 275852.
Comment 15 Alexey Proskuryakov 2024-06-30 17:43:06 PDT
I verified that the fix is present in iOS 17.6 beta source code, we didn't accidentally lose it. 

We've been unable to reproduce bug 275852 so far, so if anyone is seeing similar issues in 17.6 beta, please comment there or file new bugs.
Comment 16 Matthew Hutchinson 2024-07-01 04:37:02 PDT
Hi I've just tried my https://www.macguffinandshemp.com/iOS17test/ test on 17.6 (21G5052e). 
If I click the "audio sprite loop" button once it freezes Safari after around 200 loops. This also affects Chrome on the same device.
Comment 17 Matthew Hutchinson 2024-07-01 04:38:30 PDT
FYI 17.5.1 is not freezing so far +1000 loops and still going.
Comment 18 Ahmad Saleem 2024-07-01 08:49:25 PDT
@Matthew - I think this bug is fixed because I tried following test case (you provided prior):

Test Case: https://rayji0428.github.io/demo/howler/index.html

I tried with 6600 repeat on iOS 17.5 and iOS 17.6 Beta and they behaved same. I think bug 275852 is different from this and at least, imo this is not back.

But if you think it is reproducible, appreciate if you can open newer bug with test case, where you are able to reproduce and steps to reproduce, so we can try on our end.
Comment 19 Ahmad Saleem 2024-07-01 08:50:14 PDT
(In reply to Ahmad Saleem from comment #18)
> @Matthew - I think this bug is fixed because I tried following test case
> (you provided prior):
> 
> Test Case: https://rayji0428.github.io/demo/howler/index.html
> 
> I tried with 6600 repeat on iOS 17.5 and iOS 17.6 Beta and they behaved
> same. I think bug 275852 is different from this and at least, imo this is
> not back.
> 
> But if you think it is reproducible, appreciate if you can open newer bug
> with test case, where you are able to reproduce and steps to reproduce, so
> we can try on our end.

Sorry - test case is from someone else but again it is not reproducing while it was earlier reproducing for me.
Comment 20 Matthew Hutchinson 2024-07-01 11:07:25 PDT
Hi @ahmad I agree that this is not the same as the original bug as there is no obvious increase in memory.

The test https://www.macguffinandshemp.com/iOS17test/ does appear to freeze the browser when clicking bottom left button - audio sprite loop. 
After about 200-400 or so loops the browser will freeze. This is not happening in 17.5.

I will open a new bug but if you were able to confirm that you see this behaviour that would be useful.
Thanks
Comment 21 Ahmad Saleem 2024-07-01 11:09:09 PDT
(In reply to Matthew Hutchinson from comment #20)
> Hi @ahmad I agree that this is not the same as the original bug as there is
> no obvious increase in memory.
> 
> The test https://www.macguffinandshemp.com/iOS17test/ does appear to freeze
> the browser when clicking bottom left button - audio sprite loop. 
> After about 200-400 or so loops the browser will freeze. This is not
> happening in 17.5.
> 
> I will open a new bug but if you were able to confirm that you see this
> behaviour that would be useful.
> Thanks

That's what I did in bug 275852.

Reference - https://bugs.webkit.org/show_bug.cgi?id=275852#c12