[Webkit-unassigned] [Bug 239015] REGRESSION (Safari 15.4) Crash uploading WebGL buffers

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Apr 20 18:41:33 PDT 2022


https://bugs.webkit.org/show_bug.cgi?id=239015

--- Comment #7 from Philip Taylor <philip.taylor at zea.live> ---

1. We generate some buffers (larger than we need) using the following code.

      const attrBuffer = gl.createBuffer()
      gl.bindBuffer(gl.ARRAY_BUFFER, attrBuffer)

      const sizeInBytes = numValues * attrSpec.elementSize
      gl.bufferData(gl.ARRAY_BUFFER, sizeInBytes, gl.STATIC_DRAW)

2. We start loading our geometries, and populating the buffers using the following

      gl.bindBuffer(gl.ARRAY_BUFFER, glattrbuffer.buffer)
      gl.bufferSubData(gl.ARRAY_BUFFER, offsetInBytes, attrData.values)

3. We generate Vertex Array Objects to bind our buffers to the GPU.

    this.vao = gl.createVertexArray()
    gl.bindVertexArray(this.vao)

    ... 

4. During rendering we bind these buffers and dra.

    gl.bindVertexArray(this.vao)


   ...

    gl.drawElements(gl.TRIANGLES, counts[i], gl.UNSIGNED_INT, offsets[i])


5. Subsequently more data might be uploaded, which means we might got back to step 2 if the buffers were already big enough, else 1 if we need to allocate more space. 
  - if we need to re-allocate, we copy the data from the previous buffers into the new ones, but I have ensured this does not happen.


I used to think this bug was caused by us repeatedly increasing the size of the buffers, but that does not seem to be the case. I now pre-allocate rather big buffers so we don't need to resize them, and can still repro the problem on even small assets.

Now... it seems that if we simply generate the buffers, populate them, generate the bindings, and then draw, the performance is abysmal. 

However, if we upload more data into the buffers, then performance is perfect again.... We don't regenerate our VAOs, as they should be valid until we need to resize.

I now have simpler repros than the heavy scene I setup last week.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220421/e9992e5a/attachment.htm>


More information about the webkit-unassigned mailing list