|Summary:||[WebGL2, Safari 15 - iOS15] Problems with drawElements in some conditions|
|Product:||WebKit||Reporter:||Brendan Duncan <brendanduncan>|
|Component:||WebGL||Assignee:||Kyle Piddington <kpiddington>|
|Severity:||Normal||CC:||anthony.bowker, dino, ews-watchlist, gman, kbr, kkinnunen, kondapallykalyan, kpiddington, webkit-bug-importer|
|Version:||WebKit Nightly Build|
|Hardware:||iPhone / iPad|
|Bug Depends on:|
Description Brendan Duncan 2021-09-09 10:13:33 PDT
Comment 1 Kimmo Kinnunen 2021-09-10 02:09:12 PDT
I can confirm iPhone 12, WebGL via Metal: repros.
Comment 2 Kimmo Kinnunen 2021-09-10 02:10:06 PDT
No repro on OpenGL.
Comment 3 Kimmo Kinnunen 2021-09-10 02:12:20 PDT
Error during command buffer execution
Comment 5 Kenneth Russell 2021-09-10 12:58:24 PDT
Thanks so much Kimmo for investigating and confirming. Do you think you might be able to take this bug since only someone from Apple can really debug it? Do you think it's something ANGLE's Metal backend is doing wrong and that's the cause of the command buffer execution error? The vertex and element array buffers in this example are being allocated with DYNAMIC_DRAW. UNSIGNED_SHORT indices are being used. All of the data is zeroed out, so all of the triangles being drawn are degenerate. (All zero indices, all 0.0 vertices.)
Comment 6 Brendan Duncan 2021-09-10 13:04:42 PDT
Thanks to both of you. Please don't get hung up on the zero index and vertex buffers, and the resulting degenerate triangles. I just didn't include the array data to avoid including the giant arrays, since it still seemed to have the effect without the data. If the degenerate triangles are throwing off testing, I can include that data.
Comment 7 Brendan Duncan 2021-09-21 11:53:55 PDT
I was wondering if there was any progress identifying the issue as it will be a significant problem for Unity WebGL builds running on iOS15.
Comment 8 Kyle Piddington 2021-09-21 12:09:35 PDT
(In reply to Brendan Duncan from comment #7) > I was wondering if there was any progress identifying the issue as it will > be a significant problem for Unity WebGL builds running on iOS15. Hey Brendan, Thank you for the ping on this. I'll have a chance to look this week on what can be causing our perf issue. Our submission issue is due to a page fault in the shader. Perhaps we're not allocating enough space for our index buffer?
Comment 9 Kyle Piddington 2021-09-21 15:25:29 PDT
Created attachment 438868 [details] Repo test of a iOS15 WebGL2 problem -- Draw One Triangle Local testing
Comment 10 Kyle Piddington 2021-09-21 16:00:07 PDT
Created attachment 438875 [details] Repo test of a iOS15 WebGL2 problem - Draw No Vertex Buffer
Comment 11 Kyle Piddington 2021-09-21 16:02:22 PDT
Created attachment 438877 [details] Repo test of a iOS15 WebGL2 problem - Draw Bigger Vertex Buffer
Comment 12 Kyle Piddington 2021-09-21 16:46:36 PDT
From debugging: Adjusting the vertex array from 16384 to 16385, or to smaller (144) seem to work, In addition to adjusting the drawElements call from 158 to 159.
Comment 13 Kyle Piddington 2021-09-21 17:56:20 PDT
(In reply to Kyle Piddington from comment #12) > From debugging: > Adjusting the vertex array from 16384 to 16385, or to smaller (144) seem to > work I misread this: This isn't the vertex array. It's the index array. I think something's gone wrong with allocating exactly 4k indices. How that relates to drawing less or more, I haven't figured out yet.
Comment 14 Kyle Piddington 2021-09-21 17:57:06 PDT
(In reply to Kyle Piddington from comment #13) > I think something's gone wrong with allocating exactly 4k indices. How that > relates to drawing less or more, I haven't figured out yet. And by 4k, I meant 16k. (0x4000, got my wires crossed)
Comment 15 Kyle Piddington 2021-09-21 19:03:46 PDT
Issue appears to be in the provoking vertex index rewrite. I just spotted that the UI elements uses flat shading. Disabling index rewrite causes this to work.
Comment 17 EWS Watchlist 2021-09-21 19:18:13 PDT
Note that there are important steps to take when updating ANGLE. See https://trac.webkit.org/wiki/UpdatingANGLE
Comment 18 Brendan Duncan 2021-09-21 20:45:17 PDT
This is great! Thank you Kyle!
Comment 19 Kimmo Kinnunen 2021-09-22 04:21:46 PDT
Comment on attachment 438905 [details] Patch Looks good for what I understand. I think we "guess" that `pipelineState.maxTotalThreadsPerThreadgroup >= 64`? For obligatory nits, the first hunk is unnecessary and the second hunk you could have formatted with the command..
Comment 21 Kenneth Russell 2021-09-22 16:14:37 PDT
Comment on attachment 438963 [details] Patch Great find and fix Kyle! I defer to Dean's earlier review.
Comment 22 Kyle Piddington 2021-09-23 14:39:06 PDT
Created attachment 439094 [details] Patch for landing