RESOLVED FIXED 219378
Web Inspector: InspectorFrontendAPIDispatcher should not ignore all exceptions
https://bugs.webkit.org/show_bug.cgi?id=219378
Summary Web Inspector: InspectorFrontendAPIDispatcher should not ignore all exceptions
Blaze Burg
Reported 2020-11-30 16:15:38 PST
This makes it extremely difficult to debug problems when hacking, and it would be good to at least log exceptions that are raised by internal evaluations.
Attachments
Patch v1 (19.50 KB, patch)
2020-11-30 16:25 PST, Blaze Burg
no flags
Patch v1.1 - Fix failing test. (19.40 KB, patch)
2020-12-04 10:41 PST, Blaze Burg
no flags
Patch v1.2 - fix Debug Mac (19.98 KB, patch)
2020-12-04 11:27 PST, Blaze Burg
no flags
Blaze Burg
Comment 1 2020-11-30 16:25:15 PST
Created attachment 415074 [details] Patch v1
Blaze Burg
Comment 2 2020-11-30 16:27:35 PST
I noticed a few tests timing out locally, so I'm interested to see if this happens on the bots. In theory it shouldn't have caused tests to be any slower because it's still calling the underlying ScriptController method.
Devin Rousso
Comment 3 2020-12-01 10:53:31 PST
Comment on attachment 415074 [details] Patch v1 View in context: https://bugs.webkit.org/attachment.cgi?id=415074&action=review r=mews > Source/WebCore/inspector/InspectorFrontendClientLocal.cpp:328 > +Optional<bool> InspectorFrontendClientLocal::evaluationResultToBoolean(InspectorFrontendAPIDispatcher::EvaluationResult result) Rather than `Optional<bool>` should we always just `.valueOr(false)`? > Source/WebCore/inspector/InspectorFrontendClientLocal.cpp:334 > + if (valueOrException) I'd make this `if (!valueOrException)` so that we early-return for failure (that seems to be our usual pattern too) > Source/WebCore/inspector/InspectorFrontendClientLocal.h:137 > + Optional<bool> evaluationResultToBoolean(InspectorFrontendAPIDispatcher::EvaluationResult); Why not make this `static` in the `.cpp`? > Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp:59 > + if (!result.has_value()) { I don't think the `has_value` is needed as `operator bool` does the same thing > Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp:65 > + default: NIT: I personally prefer avoiding `default` so that if new enum values are added then there's a compile error (which brings visibility to the usage here, causing the programmer to make a conscious decision about it instead of it being silent) > Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp:77 > + if (!valueOrException.has_value()) { ditto (:59)
Blaze Burg
Comment 4 2020-12-02 10:00:33 PST
(In reply to Devin Rousso from comment #3) > Comment on attachment 415074 [details] > Patch v1 > > View in context: > https://bugs.webkit.org/attachment.cgi?id=415074&action=review > > r=mews > > > Source/WebCore/inspector/InspectorFrontendClientLocal.cpp:328 > > +Optional<bool> InspectorFrontendClientLocal::evaluationResultToBoolean(InspectorFrontendAPIDispatcher::EvaluationResult result) > > Rather than `Optional<bool>` should we always just `.valueOr(false)`? I was hesitant, but it's probably OK since this is a private method only used by this class. > > > Source/WebCore/inspector/InspectorFrontendClientLocal.cpp:334 > > + if (valueOrException) > > I'd make this `if (!valueOrException)` so that we early-return for failure > (that seems to be our usual pattern too) > > > Source/WebCore/inspector/InspectorFrontendClientLocal.h:137 > > + Optional<bool> evaluationResultToBoolean(InspectorFrontendAPIDispatcher::EvaluationResult); > > Why not make this `static` in the `.cpp`? To call JSC::JSValue::toBoolean(), we need to access the global object via m_frontendAPIDispatcher. So we'd have to pass around that context anyway. Easier to make it an instance method IMO. > > Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp:59 > > + if (!result.has_value()) { > > I don't think the `has_value` is needed as `operator bool` does the same > thing Given that this patch deals with JSValues that could be `true` or `false`, I found it hard to quickly understand when operator bool is checking the truthiness of JSValue or the Optional. This makes it explicit. > > > Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp:65 > > + default: > > NIT: I personally prefer avoiding `default` so that if new enum values are > added then there's a compile error (which brings visibility to the usage > here, causing the programmer to make a conscious decision about it instead > of it being silent) OK > > Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp:77 > > + if (!valueOrException.has_value()) { > > ditto (:59)
Blaze Burg
Comment 5 2020-12-04 10:41:23 PST
Created attachment 415429 [details] Patch v1.1 - Fix failing test.
Blaze Burg
Comment 6 2020-12-04 11:27:21 PST
Created attachment 415437 [details] Patch v1.2 - fix Debug Mac
EWS
Comment 7 2020-12-04 13:06:45 PST
Committed r270453: <https://trac.webkit.org/changeset/270453> All reviewed patches have been landed. Closing bug and clearing flags on attachment 415437 [details].
Radar WebKit Bug Importer
Comment 8 2020-12-04 13:07:17 PST
Note You need to log in before you can comment on or make changes to this bug.