KhronosGroup / WebGL

The Official Khronos WebGL Repository
Other
2.66k stars 670 forks source link

Clarify/test transferToImageBitmap() on on-screen canvases #3695

Open kainino0x opened 1 month ago

kainino0x commented 1 month ago

(To be clear I don't think this is very important, but I wrote a test case so I wanted to share it here - maybe someday it will matter enough to someone to iron out.)

transferToImageBitmap() can be called on OffscreenCanvases which are actually on-screen via transferControlToOffscreen(). Thus the compositor and transferToImageBitmap() can both try to take frames from the canvas.

Here's a sample page: https://codepen.io/kainino0x/pen/dyxoNRd

It raises issues like:

BTW in various browsers some of the canvas images will eventually "expire" if left in the background for long enough, which AFAIU is intended to be allowed with preserveDrawingBuffer: false but maybe not otherwise.

See also #3612, #3615

kainino0x commented 1 month ago

Tangentially, the sample also shows that Safari doesn't obey alpha: false on "2d" transferControlToOffscreen contexts - don't know if this is a known issue.