Bug 172206

Summary: Pinch zoom crash: A problem occurred with this web page so it was reloaded
Product: WebKit Reporter: zac spitzer <zac.spitzer>
Component: New BugsAssignee: Simon Fraser (smfr) <simon.fraser>
Status: NEW ---    
Severity: Normal CC: ahmad.saleem792, codyzhao, damodhar.meshram, fetis26, joone, kyle.goines, manalagi001, nutcasebutterfly, pabaker85, simon.fraser, tomas.brambora, webkit-bug-importer, webkit
Priority: P2 Keywords: InRadar
Version: Safari 10   
Hardware: iPhone / iPad   
OS: iOS 10   

Description zac spitzer 2017-05-16 18:53:13 PDT
From https://discussions.apple.com/message/31241336#message31241336

Load this page on an iPad, pinch zoom in and out a few times, the page will reliably crash
and show the "A problem occurred with this web page so it was reloaded" message

http://eucomp.hu/ipad3/test.html
Comment 1 Radar WebKit Bug Importer 2017-05-16 20:16:07 PDT
<rdar://problem/32239544>
Comment 3 zac spitzer 2017-05-29 21:11:23 PDT
another example https://github.com/Leaflet/Leaflet/issues/5496
Comment 4 fetis 2017-12-15 08:37:04 PST
Hello all, I was able to reproduce this issue on apple.com

The steps are next:
1. Pinch zoom in
2. Wait a bit
3. Pinch zoom out.

Here are the videos of that process. I used iPad Air2 with iOS 11.1.2
Safari view
https://youtu.be/4O-05jQr6A8

WebInspector view
https://youtu.be/fSQKVhmEp4I

See how Layers memory dramatically jumps after zoom out.

After that, I was able to reproduce this as standalone example https://codepen.io/fetis/full/VyvYMY 
the steps to reproduce are the same.

It's enough to have only 10 images pushed to compositing layer to crash Safari. It really depends on the screen size, the same amount of images is not enough for iPhone5s.

I also have the same results on the same iPad Air 2 with the latest iOS 11.2.1

In my opinion, this's a bad graphical memory management by Webkit engine. After pinch zoom out amount of memory required for Layers increases very significantly and it causes crash/page reload.
Comment 5 Simon Fraser (smfr) 2017-12-15 11:45:44 PST
http://eucomp.hu/ipad3/test.html triggers a lot of compositing because:
Frame "frame_alterlst" has position:fixed on  <div> id='bodyscroll'
Frame "frame_right_bottom" has position:fixed on  <div> id='bodyscroll'
Main frame has two frames with negative z-index
Comment 6 Simon Fraser (smfr) 2017-12-15 11:58:50 PST
https://wanaryd.com/bike-config/test.html?cc has a lot of layers too, as does http://leafletjs.com because of the maps tiles.
Comment 7 James Alley 2017-12-28 13:48:53 PST
At Yahoo! we see this issue frequently within a web app I'm working on. But I can crash Safari by pinch-zooming on many other websites. Something is not as robust as it should be. I'm disappointed no one has even been assigned to this ticket.
Comment 8 Simon Fraser (smfr) 2017-12-29 08:29:09 PST
James, please file a bug at bugreport.apple.com with your test page.
Comment 9 Damodhar 2019-10-25 04:47:27 PDT
this issue will occured when we add two iframe's side by side and pinch star scrolling.

<html>
<body>
<iframe src="https://otonomos.com/"></iframe>
<iframe src="https://otonomos.com/"></iframe>
</body>
</html>
Comment 10 zac spitzer 2019-10-25 05:01:54 PDT
which ios/safari version and device? 13.1.2 on an iPhone XR doesn't crash for me
Comment 11 Damodhar 2019-10-25 05:09:22 PDT
os: 10.3.4
Comment 12 zac spitzer 2019-10-25 05:14:34 PDT
which device? 10.3.4 was a bug fix for older phones which don't get updated anymore
Comment 13 Damodhar 2019-10-25 05:21:24 PDT
os: 10.3.4
device :iPad 4

I have this device
Comment 14 Damodhar 2019-11-09 17:22:51 PST
I got the problem where it is their problem with canvas clearRect function. I handle the canvas and it will work
Comment 15 Patrick B 2022-03-11 07:09:54 PST
Confirmed issue still persists and is reproducible using Zac Spitzer's example from 5/29/17.

URL: https://leafletjs.com/SlavaUkraini/
Device: iPhone 13 Pro
OS: iOS 15.3.1
Browser: Safari
Steps to reproduce:
1. Navigate https://leafletjs.com/SlavaUkraini/
2. Pinch to zoom into whitespace between map and text "Here we create" to the maximum zoom level
3. Scroll the page down while zoomed in until only map is in view
4. Pinch to zoom in or out
5. Page should crash

Potentially related tickets:
https://bugs.webkit.org/show_bug.cgi?id=182872
https://bugs.webkit.org/show_bug.cgi?id=235594
Comment 16 Tomas Brambora 2022-04-05 18:00:44 PDT
I can confirm creating (relatively) large compositing layers crashes iOS Safari 15.3.1.

In particular, creating a few large elements and then scaling them down with `transform: scale` reliably crashes the page.
Comment 17 Patrick B 2022-04-05 19:57:27 PDT
Confirmed this persists in iOS 15.4.1

(In reply to Patrick B from comment #15)
> Confirmed issue still persists and is reproducible using Zac Spitzer's
> example from 5/29/17.
> 
> URL: https://leafletjs.com/SlavaUkraini/
> Device: iPhone 13 Pro
> OS: iOS 15.3.1
> Browser: Safari
> Steps to reproduce:
> 1. Navigate https://leafletjs.com/SlavaUkraini/
> 2. Pinch to zoom into whitespace between map and text "Here we create" to
> the maximum zoom level
> 3. Scroll the page down while zoomed in until only map is in view
> 4. Pinch to zoom in or out
> 5. Page should crash
> 
> Potentially related tickets:
> https://bugs.webkit.org/show_bug.cgi?id=182872
> https://bugs.webkit.org/show_bug.cgi?id=235594
Comment 18 cody zhao 2022-09-06 21:21:01 PDT
Any progress on this bug?
The iOS 15.4 Safari can easily crashes when animating a layer with 1200x1200px. We are animating is "transform". This bug caused a lot of headache when user try to edit text (which will trigger the zoom in/out animation) on our text editor on iOS device.
Comment 19 siim 2022-12-15 12:33:15 PST
Any update?

5 years and still no solution...

No problem with 100 eur android phone, but 1500 eur iPhone cannot handle more than basic webpage.
Comment 20 kyle.goines 2023-06-21 13:50:58 PDT
Made an account to say this bug is alive an well in 16.5

At least we need to know if this is an issue with resource overflow or something else. if possible we need at least a more descriptive error message if you choose not to fix this.
Comment 22 Not Steve 2023-12-27 17:36:02 PST
It is amusing to see how people here are complaining about the animation crashing issues on iOS Safari. Look how the owners are playing dumb by asking for browser/iOS version numbers; they think we are idiots. 

Dear owners: IT IS ALL VERSIONS... This issue has been present since day one and it's now 2024. 

If anyone is wondering why this isn't getting fixed, I have an answer for you: This will never get fixed because Apple does not want your animated 'websites' competing with its App Store apps. Apple wants your website to be able to show just text and images; for everything else, you will have to pay to use the App Store.
Comment 23 Ahmad Saleem 2023-12-29 09:50:36 PST
(In reply to Ahmad Saleem from comment #21)
> @Simon - Could be case of we hitting zoom overflow and clamping
> effectiveZoom & setZoom would fix it?
> 
> https://searchfox.org/wubkat/source/Source/WebCore/rendering/style/
> RenderStyleSetters.h#449
> 
> https://searchfox.org/wubkat/source/Source/WebCore/rendering/style/
> RenderStyleSetters.h#550
> 
> More like inspiration from:
> https://chromium.googlesource.com/chromium/blink/+/
> c1e3af3a019a048f3f3c584a75d34c89a78f674b

-- In this: Source/WebCore/rendering/style/RenderStyleSetters.h

inline bool RenderStyle::setEffectiveZoom(float zoomLevel)
{
    // Clamp the effective zoom value to a smaller (but hopeful still large
    // enough) range, to avoid overflow in derived computations.
    float clampedEffectiveZoom = clampTo<float>(zoomLevel, 1e-6, 1e6);
    if (compareEqual(m_rareInheritedData->effectiveZoom, clampedEffectiveZoom))
        return false;
    m_rareInheritedData.access().effectiveZoom = clampedEffectiveZoom;
    return true;
}

and

-- Source/WebCore/rendering/style/BasicShapes.h

void setZoom(float zoom) { 
        ASSERT(std::isfinite(zoom) && zoom > 0);
        m_zoom = zoom;
    }

This compiles. I am not sure about second 'BasicShapes' change though.
Comment 24 siim 2023-12-29 10:25:48 PST
Do not waste your energy on this.
Comment 25 siim 2023-12-29 10:28:21 PST
Phones are getting more and more ("Most advanced" every year") but still crashing to black screen like windows 95.

Android phone from 2017 never crashes when testing same sites.