WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
146358
ScriptMessageHandlerDelegate::didPostMessage() should reuse its JSContext instance
https://bugs.webkit.org/show_bug.cgi?id=146358
Summary
ScriptMessageHandlerDelegate::didPostMessage() should reuse its JSContext ins...
Mark Lam
Reported
2015-06-26 12:36:37 PDT
Currently, ScriptMessageHandlerDelegate::didPostMessage() creates a new JSContext on every invocation. It would be more efficient to just create it once and reuse it for all subsequent calls.
Attachments
the patch.
(3.45 KB, patch)
2015-06-26 13:07 PDT
,
Mark Lam
darin
: review+
Details
Formatted Diff
Diff
patch 2: use a static JSContext.
(3.40 KB, patch)
2015-06-26 14:22 PDT
,
Mark Lam
andersca
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Mark Lam
Comment 1
2015-06-26 12:37:09 PDT
<
rdar://problem/21349359
>
Mark Lam
Comment 2
2015-06-26 13:07:06 PDT
Created
attachment 255662
[details]
the patch.
Mark Lam
Comment 3
2015-06-26 13:08:42 PDT
Comment on
attachment 255662
[details]
the patch. View in context:
https://bugs.webkit.org/attachment.cgi?id=255662&action=review
> Source/WebKit2/ChangeLog:9 > + time it is called. This is JSContext is used only once to deserialized a JSON object
typo: extra "is" before JSContext. Will fix this before landing.
Mark Lam
Comment 4
2015-06-26 14:22:34 PDT
Created
attachment 255665
[details]
patch 2: use a static JSContext. Sam pointed out offline that didPostMessage() is always called from the UI thread, and we only need a static instance if the JSContext. Updated the patch to reflect this.
Anders Carlsson
Comment 5
2015-06-26 14:47:48 PDT
Comment on
attachment 255665
[details]
patch 2: use a static JSContext. View in context:
https://bugs.webkit.org/attachment.cgi?id=255665&action=review
> Source/WebKit2/UIProcess/API/Cocoa/WKUserContentController.mm:97 > + static JSContext* context = nil; > + if (!context) > + context = [[JSContext alloc] init];
You can just assign to the variable directly.
> Source/WebKit2/UIProcess/API/Cocoa/WKUserContentController.mm:101 > + id body = [value toObject];
value.toObject?
> Source/WebKit2/UIProcess/API/Cocoa/WKUserContentController.mm:103 > + > + RetainPtr<WKScriptMessage> message = adoptNS([[WKScriptMessage alloc] _initWithBody:body webView:fromWebPageProxy(page) frameInfo:frameInfo.get() name:m_name.get()]);
I'd use auto here.
Mark Lam
Comment 6
2015-06-26 15:17:21 PDT
Thanks for the reviews. Ander's feedback as been applied. Landed in
r186010
: <
http://trac.webkit.org/r186010
>.
Mark Lam
Comment 7
2015-06-26 16:16:41 PDT
Some build bots were not liking the #import <WTF/MainThread.h>. I removed it for now in
r186014
: <
http://trac.webkit.org/r186014
> to green the bots while I investigate.
Mark Lam
Comment 8
2015-06-26 16:47:47 PDT
#inport and assertion re-added in
r186017
: <
http://trac.webkit.org/r186017
>.
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