Bug 178348 - WebGL clear not actually clearing
Summary: WebGL clear not actually clearing
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: Safari 11
Hardware: Mac macOS 10.13
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-10-16 10:42 PDT by Ashley Gullen
Modified: 2017-12-07 07:33 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ashley Gullen 2017-10-16 10:42:59 PDT
We have a WebGL-powered HTML5 game engine. We've started noticing in some cases our calls to gl.clear() are not working. I've tested a MacBook Pro mid-2015 (with Intel Iris Pro graphics). In Chrome and Firefox on the same device, as well as Edge 16 on a Windows 10 PC, it works fine. It's only Safari that seems to have a problem.

Test URL: https://www.scirra.com/labs/bugs/safariclear/
Expected result (using Chrome): https://www.scirra.com/labs/bugs/safariclear/expected.png
Observed result (in Safari 11): https://www.scirra.com/labs/bugs/safariclear/observed.png
Safari TP 41 also reproduces the problem.

Our engine uses gl.clearColor(1, 1, 1, 1) followed by gl.clear(gl.COLOR_BUFFER_BIT) to clear the background opaque white. In all other browsers this makes the background white as expected. In Safari though it appears to have no effect, leaving the background black. The background does not appear to be written to at all. The previous framebuffer contents is left behind, so as the blue box moves, it leaves behind a trail. Strangely any drawing done with an alpha channel does appear to correctly blend with the white background - the demo uses a blue texture with 1px of transparency around the edges, and that renders as white.

I suspect there's a driver bug here, but we can't figure out how to work around it. Preferably Safari would internally work around it, but it would be useful to know what we could do about it too.
Comment 1 Ashley Gullen 2017-10-16 10:44:57 PDT
Also this does not appear to reproduce in Safari on iOS 11 on an iPad Air 2. It only happens on the MacBook.
Comment 2 Radar WebKit Bug Importer 2017-10-31 00:30:17 PDT
<rdar://problem/35267358>
Comment 3 Dean Jackson 2017-11-28 13:13:48 PST
Ashley, does this consistently happen on such a device?

If it were a driver bug, then I'd expect the other browsers to have the same behaviour. What operating system are you using?
Comment 4 Dean Jackson 2017-11-28 13:15:42 PST
I tried on a few pieces of hardware and was unable to reproduce. I think I have a 2015 macbook pro. I'll boot it up to try.
Comment 5 Ashley Gullen 2017-11-28 13:45:19 PST
I tested on High Sierra. Perhaps there's a Safari bug then, but it could also be a driver bug specific to Safari's method of compositing.
Comment 6 Dean Jackson 2017-11-28 15:13:27 PST
I tried on the exact hardware and couldn't reproduce. But then I remembered this issue: https://github.com/mrdoob/three.js/issues/12598

So, it definitely happened. And it sounds like it is now resolved.
Comment 7 Ashley Gullen 2017-12-07 07:33:27 PST
I can verify this is fixed on macOS 10.13.2 in both Safari 11 and TP 45.