Hi ANGLE team,
There are a few bugs and missing features in the GL backend for macOS using CGL. It seems like this functionality isn't used by Chrome; is this backend still being developed?
I'd be happy to try and fix the issues detailed below, with some guidance. Any hints would be very appreciated :-)
Thanks!
- Joao
#1: resizing the window animates the sizing of the framebuffer, interpolating from the old size to the new size.
This happens at [1], because WebSwapCGLLayer is a CALayer and animates changes to its properties by default. Wrapping that line in a CATransaction with no animations fixes this (documented at [2]). I can send a patch if this is the right fix.
#2: resizes show an outdated frame with the previous size, every time.
This frame is drawn stretched and stays on screen if the app isn't rendering continuously. eglWaitClient isn't implemented in CGL [3] and that might be part of the problem. There's a call to drawInCGLContext right after the window resize that swaps in a texture with the obsolete size; the next call to drawInCGLContext swaps in the correct size.
However, the application already resized and swapped buffers inside the resize callback. Is it possible to implement eglWaitClient in a way that makes the upcoming eglSwapBuffers do the right thing?
#3: eglSwapInterval isn't implemented [4] and eglSwapBuffers returns as fast as possible.
The macOS documentation [5] mentions calling CGLFlushDrawable to wait for vsync and having a doublebuffered CGLContextObj (i.e. including kCGLPFADoubleBuffer in CGLChoosePixelFormat). This didn't work: swaps still return as fast as possible and the CPU is at 100%.