Created attachment 464566 [details] Unity build that breaks on iOS 16.2 We've observed Unity WebGL applications crashing during loading in iOS 16. We did some investigating and found that in Webkit's WebGLRenderingContextBase::validateTexFuncData() function, the byteLength being returned is the WASM heap size and not the image size when using the WebGL2 srcOffset variant of glTexSubImage2D, which we believe is the cause of the memory issue that's then crashing the Unity application. I'm attaching a project where we've set the Total Memory to 768 MB, and it immediately crashes on Safari in iOS 16.2, as well as a screenshot showing byteLength returning the size of the WASM array buffer.
Created attachment 464567 [details] screenshot showing the bytelength returned
Thank you for the report! Could you please confirm when this worked?
<rdar://problem/104457648>
Hi Alexey, I don't believe this is a regression in WebGL2, but a regression from WebGL1 to WebGL2. WebGL2 has the new variant of texSubImage2D that takes the WASM heap pointer and a srcOffset to the texture data. This is the variant that is reporting too much memory for the texture. In WebGLRenderingContextBase::validateTexFuncData, it returns byteLength, which it gets from pixels->byteLength(). byteLength is getting adjusted by srcOffset. However, pixels is still a view to the entire heap, so byteLength will be heapSize - srcOffset. From our understanding, this is causing even a small texture to report needing a large amount of memory.
I think this is duplicate of bug 250558 *** This bug has been marked as a duplicate of bug 250558 ***