-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add IPC documentation #97
base: main
Are you sure you want to change the base?
Conversation
MoeBazziGIT
commented
May 16, 2024
Adding or modifying an IPC message in WebKit involves several steps to ensure proper communication between classes in different processes. Here is a step-by-step guide: | ||
|
||
1. **Define the Message**: | ||
- Locate the appropriate `-messages.in` file (e.g., `WebPageMessages.in`). If a new message file is needed, it should be placed in the same directory as the class you are implementing it for and it should also be added to the directory's `Sources.txt` file, as mentioned [here](https://docs.webkit.org/Deep%20Dive/Build/AddingNewFile.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use a relative path ../Build/AddingNewFile.md
here.
https://www.mkdocs.org/user-guide/writing-your-docs/#linking-to-pages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it still links to the .html file
4f48743
to
bb96c08
Compare
bb96c08
to
062481a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the writeup.
I'm no native speaker, but perhaps at least the possessive forms could be fixed: typically I've been taught that the 's -form is for people and of -form is for things. So: abcd of WebKit, of directory, of WebContent process, ...
|
||
### Message Definitions | ||
|
||
Messages are defined in `*.messages.in` files (e.g., `WebPage.messages.in`). These files specify the structure and types of messages exchanged between processes. Each `*.messages.in` file must map to a header file with the same name (e.g., `WebPage.messages.in` maps to `WebPage.h`). These `*.messages.in` files are processed at build time to generate source code for receiving IPC messages. They support both synchronous and asynchronous messages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to pick some other interface than WebPage, WebPageProxy. They're the most complex of the classes, and also use the MessageSender, which is not advised.
There's no good examples, but IPCTester should be a simple one perhaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked WebPage and WebPageProxy because I could use simple message examples like LoadURL
that represent how APIs in the UI process (like WKWebView) control and interact with actual web processes. However, I understand the issue with MessageSender. I dont know if IPCTester is the best example, because its not clear where it gets its IPC::Connection object from - also, I would like to use an example class that is actually used for IPC in WebKit.
I dug around and found RemoteAudioSessionProxy - it inherits from MessageReceiver and owns an IPC::Connection object to send messages, is this the correct semantics? If so, Ill try to find another similar class that isnt so "niche" as RemoteAudioSessionProxy that uses the same semantics, but if not, ill just use it.
If this example still isnt good, and there is no other option, Ill use IPCTester as you mentioned, but ill need to figure out how to explain how its using IPC::Connection
|
||
Classes that send or receive IPC messages typically inherit from `IPC::MessageSender` and `IPC::MessageReceiver`. These base classes automatically handle the serialization and deserialization of messages, as well as the setup of message dispatching. | ||
|
||
For a deeper dive, you can found WebKit's IPC code in the `Source/WebKit/Platform/IPC` directory. This directory contains the classes and utilities needed to manage IPC, including message sending and receiving, connection management, and the serialization and deserialization of messages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably could be rewritten and moved to either to the beginning or to the end.
|
||
### IPC::MessageSender and IPC::MessageReceiver | ||
|
||
Classes that send or receive IPC messages typically inherit from `IPC::MessageSender` and `IPC::MessageReceiver`. These base classes automatically handle the serialization and deserialization of messages, as well as the setup of message dispatching. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MessageSender should not be used in general, so it should not be documented.
What should be said is that messages are sent to the connection, with the receiver destination id.
For a given class, it is advised to add a helper send template to pass in the target object identifier as the destination id. If the connection only has one receiver of the type, the helper is not needed an zero destination can be used.