Bug 234913 - Safari iOS stops rendering after switching away and back when using RobotoBold Font
Summary: Safari iOS stops rendering after switching away and back when using RobotoBol...
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Keywords: InRadar
Depends on:
Reported: 2022-01-06 00:41 PST by Gregg Tavares
Modified: 2022-02-10 11:04 PST (History)
9 users (show)

See Also:

repo for issue above (90.01 KB, application/zip)
2022-01-06 00:41 PST, Gregg Tavares
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gregg Tavares 2022-01-06 00:41:31 PST
Created attachment 448469 [details]
repo for issue above

Steps to repo

1) Download the zip file, unzip, serve the file (npx servez), open test.html in Safari on iOS (http://<your-mac-ip-address>:8080/test.html)
2) Switch from Safari to the home screen, wait a few seconds
3) Switch back to Safari

What should happen:

you should see some text "Hello World" and "Round 1" animating as well as a count counting up

What happens instead:

No animation happens

Here's a video of it happening ( https://www.youtube.com/watch?v=FftyV0iYtJw ) Notice after going back to Safari the counter is no longer updating

If you go change line 115 from "RobotoBold" to "monospace" and follow the steps above (kill the tab first), you'll see with "monospace" the animation does not stop.

HEre's a video of it working with "monospace" ( https://www.youtube.com/watch?v=g8rKxxayZHw ). notice after going back to Safari the counter is still updating

The sample uses `setInterval` (yea, I know, it should use rAF, the code that provoked this is probably > 10 year old)

If you use the remote debugger, after restoring safari, and put a breakpoint on `draw` you'll see it only gets called once every several seconds and though it is calling drawing functions none of them are affecting the canvas. Further, often you can't even refresh the tab in Safari. You can kill the tab and start a new one though.

My understanding is this worked on iOS 14 (don't have iOS 14 to test but the person that found the bug originally said their site broke when they upgraded to iOS 15). This is the small repo.
Comment 1 Gregg Tavares 2022-01-06 00:49:06 PST
Also note, FWIW, switching to rAF seems to fix the issue. Change the code from

   setInterval(draw, 10);


   // setInterval(draw, 10);
   function animate() {

It's great there's a workaround but it seems like some kind of memory corruption is happening in the bad case given that setInterval starts running at ~5-10 seconds per callback instead of 10ms and that drawing commands don't actually draw and that refresh fails.
Comment 2 Kenneth Russell 2022-01-06 13:00:26 PST
CC'ing myself and another colleague.
Comment 3 Kenneth Russell 2022-01-06 13:00:43 PST
CC'ing another colleague.
Comment 4 Kimmo Kinnunen 2022-01-10 02:24:11 PST
Thanks for the report. I cannot immediately repro with trunk. Trying with an older release.
Comment 5 Radar WebKit Bug Importer 2022-01-13 00:42:17 PST
Comment 6 Dean Jackson 2022-01-13 09:01:47 PST
This is amazing.
Comment 7 Kimmo Kinnunen 2022-01-16 23:57:52 PST
I think this is fixed with trunk. I could repro it on iPad8,3 on 15.3 seed, but could not repro on trunk. We had canvas rendering IPC changed to other implementation in between.
Comment 8 Jon Lee 2022-02-10 11:04:34 PST
Please check on the 15.4 seeds. If this still reproduces there, please reopen.