For large WebGL contexts, WebGL is spending a lot of time in allocating new Metal textures for default frame buffer backing store Conditions: 1. Somewhat large WebGL context (e.g. fullscreen MacBookPro19,1 3072x1920) 2. Somewhat non-trivial amount of WebGL drawing (e.g. converting 4K video to texture via texImage2D and drawing it) Causes a scenario where somehow WindowServer does not let the WebGL display buffers go, e.g. the IOSurface IsInUse property remains false when WebGL tries to obtain a new drawing buffer. This causes WebGL to allocate a new drawing buffer. Allocating the IOSurface seems to be fast, but then creating a Metal texture out of it seems to be slow. Sampling reveals a lot of samples in [MTL...Device newTextureWithDescriptor:iosurface:plane:] Reproable for example in 4k 360 YouTube: - https://www.youtube.com/watch?v=HKNI658SKJ4 - Let it load and observe sharp rendering - Stop the video - Rotate the video around with WASD keys - Vary the window size: small sized windows are smooth, large sized windows start to skip frames
<rdar://problem/80024974>
Reproducible at least on MacBookPro19,1 Intel/AMD. Metal selects Intel always.
Sample Count, Samples %, Normalized CPU %, Symbol 1367, 8.7%, 1.8%, WebCore::Document::prepareCanvasesForDisplayIfNeeded() (in WebCore) 1234, 7.8%, 1.6%, WebCore::GraphicsContextGLOpenGL::prepareForDisplay() (in WebCore) 1100, 7.0%, 1.4%, WebCore::GraphicsContextGLOpenGL::allocateAndBindDisplayBufferBacking() (in WebCore) 1100, 7.0%, 1.4%, EGL_BindTexImage (in libANGLE-shared.dylib) 1100, 7.0%, 1.4%, egl::Surface::bindTexImage(gl::Context*, gl::Texture*, int) (in libANGLE-shared.dylib) 1063, 6.7%, 1.4%, rx::IOSurfaceSurfaceMtl::bindTexImage(gl::Context const*, gl::Texture*, int) (in libANGLE-shared.dylib) 1054, 6.7%, 1.4%, rx::IOSurfaceSurfaceMtl::ensureColorTextureCreated(gl::Context const*) (in libANGLE-shared.dylib) 1004, 6.4%, 1.3%, -[MTL..AccelDevice newTextureWithDescriptor:iosurface:plane:] (in ....)