[Gecko iOS] Get Gecko booting on-device
Categories
(Core :: IPC, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox148 | --- | fixed |
People
(Reporter: nika, Assigned: nika)
References
(Blocks 1 open bug)
Details
Attachments
(8 files, 12 obsolete files)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review |
| Assignee | ||
Comment 1•1 year ago
|
||
| Assignee | ||
Comment 2•1 year ago
|
||
The __IS_NOT_SIMULATOR environment variable I found some reference to online - it appears to not exist so everything falls over due to being unsigned if I continue to check it. This may break simulator builds, but I haven't looked into it yet.
Depends on D227098
| Assignee | ||
Comment 3•1 year ago
|
||
Depends on D227099
| Assignee | ||
Comment 4•1 year ago
|
||
This depended on the libevent event loop, which is not going to work in iOS content processes due to the sandbox blocking the kevent syscall.
Depends on D227100
| Assignee | ||
Comment 5•1 year ago
|
||
Depends on D227101
| Assignee | ||
Comment 6•1 year ago
|
||
Depends on D227102
| Assignee | ||
Comment 7•1 year ago
|
||
PC will be used as the temporary IPC backend, so we need to be able to pass XPC endpoints on the command line.
Depends on D227103
| Assignee | ||
Comment 8•1 year ago
|
||
This approach, especially in its current form, has quite a bit of overhead, but
should help us get some prototyping done for iOS. In the future, we'll probably
want to directly use mach ports, either with a kevent-based message loop (if
that syscall is unblocked) or with a libdispatch queue replacing our IPC IO
Thread.
This also required shimming out the process watcher, which also used the libevent pump.
Depends on D227104
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
| Assignee | ||
Comment 9•1 year ago
|
||
This is a temporary hack because the I/O thread currently being used on iOS can't initialise BHR or it will crash - I want to fix this.
Depends on D227105
| Assignee | ||
Comment 10•1 year ago
|
||
Depends on D227287
| Assignee | ||
Comment 11•1 year ago
|
||
Depends on D227288
| Assignee | ||
Comment 12•1 year ago
|
||
Depends on D227289
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
| Assignee | ||
Comment 13•1 year ago
|
||
This reduces the number of required thread hops when sending messages over IPC
by having the IO thread be the libdispatch queue connected to the xpc
connection.
Depends on D227105
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
| Assignee | ||
Comment 14•1 year ago
|
||
Status update: With this patch stack + the other patches on cedar, we're able to boot a proof-of-concept version of Gecko on an iOS 18.2 beta device. This requires us to build for aarch64, rather than arm64e. So far the main changes which are required in the stack are around the sandbox blocking some core IPC methods (specifically kevent and kevent64), and a bug with BrowserEngineCore on-device with aarch64, which we have filed in feedback assistant.
https://phabricator.services.mozilla.com/D227740 contains the code to work around the BrowserEngineCore bug using inline assembly - though hopefully Apple will fix this upstream and we won't need it. Without this change, the JIT crashes early during startup.
In terms of IPC sandboxing issues, we encountered 2 major issues:
- We use mach task_t ports in order to transfer mach send rights between processes on iOS, combined with a unix domain socket for sending IPC payloads. Transferring a mach task port to the parent process over XPC appears to be blocked by the content process sandbox, so we cannot use this strategy on iOS (https://phabricator.services.mozilla.com/D227102)
- Even without the ability to transfer mach ports, we cannot start our IPC connection, as the
keventsyscall used bylibeventfor async I/O is blocked by the content process sandbox. It appears the only variant of this syscall not blocked by the sandbox isSYS_kevent_qos- an apple internal API used bylibdispatch, so we need to use a libdispatch-based async I/O backend.- For simplicity in the initial implementation, this is currently being done by an XPC-based IPC channel implementation running on a libdispatch queue. There's a good chance we'll want to switch this to use a lower-level primitive like mach ports in the future, especially if the IPC overhead starts appearing in profiles.
- This temporary implementation also ended up requiring some refactoring as we couldn't easily use our fork of the chromium IPC I/O loop, due to the libdispatch public interface. This is being done in bug 1928734.
| Assignee | ||
Comment 15•1 year ago
|
||
One of the sources of complexity in this current patch stack is the need to change the model we use for the I/O thread to instead use a libdispatch event target. I took another stab at keeping the I/O thread by using a CFRunLoop-based thread and CFFileDescriptor (https://developer.apple.com/documentation/corefoundation/cffiledescriptor?language=objc) to watch file descriptors. Unfortunately, the CFFileDescriptorCreate call seems to be blocked by the iOS WebContent and Rendering sandboxes (but not the networking sandbox). AFAICT this is because it calls fcntl(.., F_DUPFD_CLOEXEC) under the hood, which is not an allowed fcntl call. I can't easily check for other issues past that point.
I expect that using CFRunLoop for watching mach ports will work OK. FD handling appears to not be in the swift-corelibs-foundation, but parts of the runloop backend are open source, and it appears CFRunLoop uses a mach port set and mach_msg to wait for messages (https://github.com/swiftlang/swift-corelibs-foundation/blob/21b3196b33a64d53a0989881fc9a486227b4a316/Sources/CoreFoundation/CFRunLoop.c#L3100). That being said, it might be simpler to directly call mach_msg in that case, though, rather than calling indirectly through CoreFoundation.
Based on the CFRunLoop source, it appears there's no handling for file descriptors in CFRunLoopRun. The CFRunLoopSource produced by CFFileDescriptorCreateRunLoopSource (in a non-sandboxed process) doesn't have a version 1 context with a mach_port_t (which would be added to the port set). This suggests that something like libdispatch is being used to watch FDs on a background thread, and notifications are then dispatched to the CFRunLoopSource. This can probably be done in user code as well if FD watchers are needed (though I believe Gecko could probably get away without them on iOS, if we switch to mach ports for IPC).
I'll probably look into a mach port set based IO thread more, as it's probably less invasive than using a libdispatch queue.
| Assignee | ||
Comment 16•1 year ago
|
||
Depends on D227290
| Assignee | ||
Comment 17•1 year ago
|
||
This requires adding a call to texImageIOSurface, which is only available
on-device, so cannot be used for simulator builds. We will need to come up with
another soltuion for simulator, which may reqire a non-IOSurface-based backend.
In addition, the compositor code needs to be changed to use GL_TEXTURE_2D
instead of GL_TEXTURE_RECTANGLE, as that type doesn't exist for OpenGL ES on
iOS.
Depends on D229402
Updated•1 year ago
|
| Assignee | ||
Comment 18•1 year ago
|
||
Depends on D229403
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
| Assignee | ||
Comment 19•1 year ago
|
||
As of the iOS 18.2 SDK, the definition of
be_memory_inline_jit_restrict_rwx_to_rw_with_witness on non-arm64e uses both a
numeric 1: label, and a %= label. In the case where LLVM selects that the
%= label should be the number '1', this leads to a miscompilation (and
crash), as the adr x0, %=f expression loads the incorrect address into x0.
To work around this until the definition is fixed, this patch adds two empty
__asm__ blocks before the library call. This ensures that there are at least
2 LLVM IR call void asm sideeffect "${:uid}" blocks incrementing the value
for %= before the problematic function, avoiding the miscompilation. They are
placed within the same function to ensure that they cannot be eliminated or
re-ordered by the compiler, as the order of the blocks in the post-optimization
IR appears to be what controls the value of the %= label.
Depends on D230338
| Assignee | ||
Comment 20•1 year ago
|
||
The locked down iOS sandbox appears to block attempts to read the localtime
after the lockdown is in place. As it appears localtime information is required
in content processes for HTTP header parsing, we need to access this
information (loading it into the cache), before the sandbox is locked down.
Depends on D233422
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Comment 21•1 year ago
|
||
Comment on attachment 9433778 [details]
WIP: Bug 1927599 - Part 5: Properly set small alloc randomization for iOS content processes, r=jld!
Revision D227103 was moved to bug 1945252. Setting attachment 9433778 [details] to obsolete.
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
| Assignee | ||
Comment 22•1 year ago
|
||
This is the sandboxing implementation on macOS, and is not relevant on iOS
where sandboxing profiles are provided by the OS.
Depends on D230338
| Assignee | ||
Comment 23•1 year ago
|
||
Depends on D251641
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•10 months ago
|
Updated•10 months ago
|
Comment 24•9 months ago
|
||
Comment 25•9 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/30519656e5dd
https://hg.mozilla.org/mozilla-central/rev/09a79d174467
https://hg.mozilla.org/mozilla-central/rev/c5b8ecb22d85
https://hg.mozilla.org/mozilla-central/rev/0e8627bb43f4
https://hg.mozilla.org/mozilla-central/rev/9ac236f5314a
https://hg.mozilla.org/mozilla-central/rev/e562cebaefcd
https://hg.mozilla.org/mozilla-central/rev/19da8ee802cc
https://hg.mozilla.org/mozilla-central/rev/18a01c664262
Description
•