WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
190746
Introduce CompletionHandler-based Async IPC messages with replies
https://bugs.webkit.org/show_bug.cgi?id=190746
Summary
Introduce CompletionHandler-based Async IPC messages with replies
Alex Christensen
Reported
2018-10-18 23:53:00 PDT
Introduce CompletionHandler-based Async IPC messages with replies
Attachments
Patch
(29.82 KB, patch)
2018-10-19 00:04 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(29.83 KB, patch)
2018-10-19 00:10 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(31.98 KB, patch)
2018-10-19 07:44 PDT
,
Alex Christensen
thorton
: review+
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Alex Christensen
Comment 1
2018-10-19 00:04:43 PDT
Created
attachment 352773
[details]
Patch
Alex Christensen
Comment 2
2018-10-19 00:10:51 PDT
Created
attachment 352774
[details]
Patch
Alex Christensen
Comment 3
2018-10-19 07:44:04 PDT
Created
attachment 352783
[details]
Patch
Alex Christensen
Comment 4
2018-10-19 09:54:15 PDT
Tim wants to know from Anders why this wasn't already done.
Alex Christensen
Comment 5
2018-10-19 10:05:14 PDT
(like if there's a good reason to not do it or if it just hasn't been done yet)
Tim Horton
Comment 6
2018-10-19 10:25:54 PDT
Comment on
attachment 352783
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=352783&action=review
> Source/WebKit/ChangeLog:11 > + What a mess. No wonder people take shortcuts and make strange design decisions.
Hah. Ouch.
> Source/WebKit/ChangeLog:15 > + layout test and many others. I intent to refine and further adopt this incrementally.
You intent!
> Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in:59 > + GetSandboxExtensionsForBlobFiles(Vector<String> paths) -> (WebKit::SandboxExtension::HandleArray extensions) Async
I feel like we should either invert the sync-by-default or make you always write one or the other. But that can be later.
Alex Christensen
Comment 7
2018-10-19 10:41:28 PDT
Comment on
attachment 352783
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=352783&action=review
http://trac.webkit.org/r237294
> Source/WebKit/Platform/IPC/Connection.cpp:1137 > +CompletionHandler<void(Decoder*)> takeAsyncReplyHandler(Connection& connection, uint64_t identifier)
As suggested by Anders, I added the equivalent of MESSAGE_CHECK(map.isValidKey(identifier)) here because it's coming from an untrusted source.
Alex Christensen
Comment 8
2018-10-19 10:41:44 PDT
http://trac.webkit.org/r237294
Radar WebKit Bug Importer
Comment 9
2018-10-19 10:42:26 PDT
<
rdar://problem/45409444
>
Alex Christensen
Comment 10
2018-10-19 13:18:38 PDT
http://trac.webkit.org/r237298
Simon Fraser (smfr)
Comment 11
2018-10-19 21:57:02 PDT
Do we expect all callers to be on the main thread?
Chris Dumez
Comment 12
2018-10-22 08:55:55 PDT
(In reply to Simon Fraser (smfr) from
comment #11
)
> Do we expect all callers to be on the main thread?
This definitely has not been a requirement so far for async IPC. I do not think we should add such requirement either.
Simon Fraser (smfr)
Comment 13
2018-10-22 08:57:34 PDT
Do you need to protect asyncReplyHandlerMap() with a lock then?
Chris Dumez
Comment 14
2018-10-22 09:18:22 PDT
(In reply to Simon Fraser (smfr) from
comment #13
)
> Do you need to protect asyncReplyHandlerMap() with a lock then?
I will look into the patch more but there might be other issues also: - ID generation is not thread safe - CompletionHandlers may not get called on the thread that scheduled them.
Chris Dumez
Comment 15
2018-10-22 09:26:36 PDT
Comment on
attachment 352783
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=352783&action=review
> Source/WebKit/Platform/IPC/Connection.cpp:284 > + handler(nullptr);
The Connection destructor is always called on the main thread so those completion handlers will be called on the main thread no matter on which thread they were scheduled.
> Source/WebKit/Platform/IPC/Connection.cpp:970 > + auto handler = takeAsyncReplyHandler(*this, *listenerID);
Looks like the map is only used from the main thread here.
> Source/WebKit/Platform/IPC/Connection.h:419 > +void Connection::sendWithAsyncReply(T&& message, CompletionHandler<void(Args...)>&& completionHandler, uint64_t destinationID)
I see that you added a new method. We may want to add ASSERT(RunLoop::isMain()); in this method and in nextAsyncReplyHandlerID() and in asyncReplyHandlerMap() since those are not thread safe. In the future we have have some use cases for calling this on background threads though as the regular send() allows this.
Alex Christensen
Comment 16
2019-06-28 10:17:37 PDT
Adding assertions in
https://bugs.webkit.org/show_bug.cgi?id=199324
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