RESOLVED FIXED 214999
[WebGL2] Assert when restoring lost context
https://bugs.webkit.org/show_bug.cgi?id=214999
Summary [WebGL2] Assert when restoring lost context
James Darpinian
Reported 2020-07-30 17:41:51 PDT
[WebGL2] Assert when restoring lost context
Attachments
Patch (1.67 KB, patch)
2020-07-30 17:42 PDT, James Darpinian
no flags
Patch (1.52 KB, patch)
2020-07-31 17:35 PDT, James Darpinian
no flags
James Darpinian
Comment 1 2020-07-30 17:42:34 PDT
Darin Adler
Comment 2 2020-07-30 19:10:09 PDT
Comment on attachment 405644 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405644&action=review > Source/WebCore/html/canvas/WebGL2RenderingContext.cpp:215 > + // If we're restoring a lost context, we should delete the old default VAO before creating the new one. > + m_defaultVertexArrayObject = nullptr; This points to a design problem. Decrementing the reference count on a reference counted object is not guaranteed to delete the object. If we need control of timing of object deletion then it’s not good to be using reference counted objects.
Darin Adler
Comment 3 2020-07-30 19:11:20 PDT
Comment on attachment 405644 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405644&action=review >> Source/WebCore/html/canvas/WebGL2RenderingContext.cpp:215 >> + m_defaultVertexArrayObject = nullptr; > > This points to a design problem. Decrementing the reference count on a reference counted object is not guaranteed to delete the object. If we need control of timing of object deletion then it’s not good to be using reference counted objects. I suppose we could just write in a comment here the reason why we are guaranteed there is no one else holding a reference to this. Or we could come up with a way to do the deletion explicitly other than destroying the C++ reference counted thing.
James Darpinian
Comment 4 2020-07-31 00:02:36 PDT
Comment on attachment 405644 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405644&action=review >>> Source/WebCore/html/canvas/WebGL2RenderingContext.cpp:215 >>> + m_defaultVertexArrayObject = nullptr; >> >> This points to a design problem. Decrementing the reference count on a reference counted object is not guaranteed to delete the object. If we need control of timing of object deletion then it’s not good to be using reference counted objects. > > I suppose we could just write in a comment here the reason why we are guaranteed there is no one else holding a reference to this. Or we could come up with a way to do the deletion explicitly other than destroying the C++ reference counted thing. Sorry, "delete" is the wrong word. The object does not need to be deleted, it just needs to be disassociated from the context. I will fix the comment.
Darin Adler
Comment 5 2020-07-31 11:04:13 PDT
Comment on attachment 405644 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405644&action=review >>>> Source/WebCore/html/canvas/WebGL2RenderingContext.cpp:215 >>>> + m_defaultVertexArrayObject = nullptr; >>> >>> This points to a design problem. Decrementing the reference count on a reference counted object is not guaranteed to delete the object. If we need control of timing of object deletion then it’s not good to be using reference counted objects. >> >> I suppose we could just write in a comment here the reason why we are guaranteed there is no one else holding a reference to this. Or we could come up with a way to do the deletion explicitly other than destroying the C++ reference counted thing. > > Sorry, "delete" is the wrong word. The object does not need to be deleted, it just needs to be disassociated from the context. I will fix the comment. I’d like to understand what "disassociated" means. Does it literally just mean that m_defaultVertexArrayObject must be null?
Darin Adler
Comment 6 2020-07-31 11:04:44 PDT
Comment on attachment 405644 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405644&action=review >>>>> Source/WebCore/html/canvas/WebGL2RenderingContext.cpp:215 >>>>> + m_defaultVertexArrayObject = nullptr; >>>> >>>> This points to a design problem. Decrementing the reference count on a reference counted object is not guaranteed to delete the object. If we need control of timing of object deletion then it’s not good to be using reference counted objects. >>> >>> I suppose we could just write in a comment here the reason why we are guaranteed there is no one else holding a reference to this. Or we could come up with a way to do the deletion explicitly other than destroying the C++ reference counted thing. >> >> Sorry, "delete" is the wrong word. The object does not need to be deleted, it just needs to be disassociated from the context. I will fix the comment. > > I’d like to understand what "disassociated" means. Does it literally just mean that m_defaultVertexArrayObject must be null? Could you clarify what the specific issue is? I understand roughly but not fully.
James Darpinian
Comment 7 2020-07-31 15:48:31 PDT
Comment on attachment 405644 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405644&action=review >>>>>> Source/WebCore/html/canvas/WebGL2RenderingContext.cpp:215 >>>>>> + m_defaultVertexArrayObject = nullptr; >>>>> >>>>> This points to a design problem. Decrementing the reference count on a reference counted object is not guaranteed to delete the object. If we need control of timing of object deletion then it’s not good to be using reference counted objects. >>>> >>>> I suppose we could just write in a comment here the reason why we are guaranteed there is no one else holding a reference to this. Or we could come up with a way to do the deletion explicitly other than destroying the C++ reference counted thing. >>> >>> Sorry, "delete" is the wrong word. The object does not need to be deleted, it just needs to be disassociated from the context. I will fix the comment. >> >> I’d like to understand what "disassociated" means. Does it literally just mean that m_defaultVertexArrayObject must be null? > > Could you clarify what the specific issue is? I understand roughly but not fully. There's just an assert in WebGLVertexArrayObject::create that m_defaultVertexArrayObject is null when creating an object with Type::Default, I suppose to prevent people accidentally specifying Type::Default when they didn't mean to. Since that seems unlikely, an alternative approach would be to simply remove the assert.
James Darpinian
Comment 8 2020-07-31 17:35:46 PDT
EWS
Comment 9 2020-08-03 10:49:19 PDT
Committed r265205: <https://trac.webkit.org/changeset/265205> All reviewed patches have been landed. Closing bug and clearing flags on attachment 405763 [details].
Radar WebKit Bug Importer
Comment 10 2020-08-03 13:38:08 PDT
Note You need to log in before you can comment on or make changes to this bug.