How about your idea that after every call to glGenXXX, glCreateXXX, glBufferData, glTexImage2D, glCopyImage2D, and glRenderbufferStorage the browser would check for GL_OUT_OF_MEMORY, then if so do a GC and then try the call again?

Implementations are free to do this if they want, but it's a separate issue. ÂI don't know if other JS APIs do this sort of thing under memory pressure.

By the way, remember that GPUs aren't limited to GPU memory: when low on memory, textures are swapped out to main memory (speaking roughly), and you can allocate far more texture memory than you have GPU space. ÂThis means that if you're hitting GL_OOM, you're probably running out of main memory, not just GPU memory.