WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 204395
Web Inspector: Canvas: adjust `InspectorCanvasAgent::recordCanvasAction` to actually check that the `CanvasRenderingContext` still exists
https://bugs.webkit.org/show_bug.cgi?id=204395
Summary
Web Inspector: Canvas: adjust `InspectorCanvasAgent::recordCanvasAction` to a...
Devin Rousso
Reported
2019-11-19 21:12:51 PST
The microtask we create inside `InspectorCanvasAgent::recordCanvasAction` to handle marking the end of a frame for a detached canvas doesn't actually check that the `CanvasRenderingContext` still exists, such as if the `CanvasRenderingContext` gets GCd during a recording.
Attachments
Patch
(3.89 KB, patch)
2019-11-19 21:25 PST
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
Patch
(6.82 KB, patch)
2019-11-20 10:29 PST
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
Patch
(7.15 KB, patch)
2019-11-21 21:24 PST
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
Patch
(7.15 KB, patch)
2019-11-21 21:28 PST
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Devin Rousso
Comment 1
2019-11-19 21:13:00 PST
<
rdar://problem/57347504
>
Devin Rousso
Comment 2
2019-11-19 21:25:49 PST
Created
attachment 383944
[details]
Patch
Ryosuke Niwa
Comment 3
2019-11-19 23:07:49 PST
Comment on
attachment 383944
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=383944&action=review
> Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp:456 > + MicrotaskQueue::mainThreadQueue().append(makeUnique<VoidMicrotask>([&, canvasId = inspectorCanvas->identifier()] { > + auto inspectorCanvas = m_identifierToInspectorCanvas.get(canvasId); > + if (!inspectorCanvas)
How do we know InspectorCanvasAgent is still alive?
Devin Rousso
Comment 4
2019-11-20 09:27:36 PST
Comment on
attachment 383944
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=383944&action=review
>> Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp:456 >> + if (!inspectorCanvas) > > How do we know InspectorCanvasAgent is still alive?
That's a really good point! Although I'd imagine it's exceedingly rare, I think It is possible for Web Inspector to close before this microtask callback is executed.
Devin Rousso
Comment 5
2019-11-20 10:29:46 PST
Created
attachment 383971
[details]
Patch
Ryosuke Niwa
Comment 6
2019-11-20 17:35:46 PST
Comment on
attachment 383971
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=383971&action=review
> Source/WebCore/inspector/agents/InspectorCanvasAgent.h:169 > + RecordCanvasActionMicrotask* m_recordCanvasActionMicrotask { nullptr };
Can we just make InspectorCanvasAgent inherit from CanMakeWeakPtr and use that instead? Storing raw pointer to RecordCanvasActionMicrotask* doesn't seem like a great long term strategy.
Devin Rousso
Comment 7
2019-11-21 11:11:28 PST
Comment on
attachment 383971
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=383971&action=review
>> Source/WebCore/inspector/agents/InspectorCanvasAgent.h:169 >> + RecordCanvasActionMicrotask* m_recordCanvasActionMicrotask { nullptr }; > > Can we just make InspectorCanvasAgent inherit from CanMakeWeakPtr and use that instead? > Storing raw pointer to RecordCanvasActionMicrotask* doesn't seem like a great long term strategy.
We could do that, but it would require a much larger change, as we use `std::unique_ptr` to hold all of our agents. I'll investigate shifting everything from `std::unique_ptr` to `Ref`.
Ryosuke Niwa
Comment 8
2019-11-21 19:33:51 PST
(In reply to Devin Rousso from
comment #7
)
> Comment on
attachment 383971
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=383971&action=review
> > >> Source/WebCore/inspector/agents/InspectorCanvasAgent.h:169 > >> + RecordCanvasActionMicrotask* m_recordCanvasActionMicrotask { nullptr }; > > > > Can we just make InspectorCanvasAgent inherit from CanMakeWeakPtr and use that instead? > > Storing raw pointer to RecordCanvasActionMicrotask* doesn't seem like a great long term strategy. > > We could do that, but it would require a much larger change, as we use > `std::unique_ptr` to hold all of our agents. I'll investigate shifting > everything from `std::unique_ptr` to `Ref`.
?? WeakPtr is totally compatible with std::unique_ptr.
Ryosuke Niwa
Comment 9
2019-11-21 19:35:24 PST
e.g. you can do: class A : public CanMakeWeak<A> { }; auto a = makeUnique<A>; auto weakPtrToA = makeWeakPtr(a); a = nullptr; weakPtrToA.get() // this will be nullptr here.
Devin Rousso
Comment 10
2019-11-21 20:54:14 PST
Comment on
attachment 383971
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=383971&action=review
>>>> Source/WebCore/inspector/agents/InspectorCanvasAgent.h:169 >>>> + RecordCanvasActionMicrotask* m_recordCanvasActionMicrotask { nullptr }; >>> >>> Can we just make InspectorCanvasAgent inherit from CanMakeWeakPtr and use that instead? >>> Storing raw pointer to RecordCanvasActionMicrotask* doesn't seem like a great long term strategy. >> >> We could do that, but it would require a much larger change, as we use `std::unique_ptr` to hold all of our agents. I'll investigate shifting everything from `std::unique_ptr` to `Ref`. > > ?? WeakPtr is totally compatible with std::unique_ptr.
Interesting. I was under the (apparently incorrect) assumption that `WeakPtr` required the type to be `RefCounted`.
Ryosuke Niwa
Comment 11
2019-11-21 21:12:00 PST
(In reply to Devin Rousso from
comment #10
)
> Comment on
attachment 383971
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=383971&action=review
> > >>>> Source/WebCore/inspector/agents/InspectorCanvasAgent.h:169 > >>>> + RecordCanvasActionMicrotask* m_recordCanvasActionMicrotask { nullptr }; > >>> > >>> Can we just make InspectorCanvasAgent inherit from CanMakeWeakPtr and use that instead? > >>> Storing raw pointer to RecordCanvasActionMicrotask* doesn't seem like a great long term strategy. > >> > >> We could do that, but it would require a much larger change, as we use `std::unique_ptr` to hold all of our agents. I'll investigate shifting everything from `std::unique_ptr` to `Ref`. > > > > ?? WeakPtr is totally compatible with std::unique_ptr. > > Interesting. I was under the (apparently incorrect) assumption that > `WeakPtr` required the type to be `RefCounted`.
Yeah, it's a common misconception. WeakPtr uses RefPtr as its implementation detail but it's a completely independent feature from RefCounted. Also, Ref/RefPtr doesn't rely on RefCounted either. They just require the object to have ref() and deref() functions. WebCore's Node, for example, doesn't inherit from RefCounted but it's still used with Ref & RefPtr.
Devin Rousso
Comment 12
2019-11-21 21:24:42 PST
Created
attachment 384122
[details]
Patch
Devin Rousso
Comment 13
2019-11-21 21:28:57 PST
Created
attachment 384123
[details]
Patch Oops. Small typo.
Ryosuke Niwa
Comment 14
2019-11-21 21:46:23 PST
Comment on
attachment 384123
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=384123&action=review
The mechanism WeakPtr part of the change looks good but perhaps someone familiar with WebInspector should also review this code change too.
> Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp:454 > + scriptExecutionContext->eventLoop().queueMicrotask([weakThis = makeWeakPtr(*this)] {
This change makes sense to me.
Timothy Hatcher
Comment 15
2019-11-22 12:06:04 PST
Comment on
attachment 384123
[details]
Patch Looks fine to me.
Blaze Burg
Comment 16
2019-11-22 12:11:25 PST
Comment on
attachment 384123
[details]
Patch LGTM
WebKit Commit Bot
Comment 17
2019-11-22 12:29:32 PST
Comment on
attachment 384123
[details]
Patch Clearing flags on attachment: 384123 Committed
r252792
: <
https://trac.webkit.org/changeset/252792
>
WebKit Commit Bot
Comment 18
2019-11-22 12:29:34 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug