-
-
Notifications
You must be signed in to change notification settings - Fork 148
feat: Electron-compat shim + experimental Servo web-engine switch #5811
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
Draft
proggeramlug
wants to merge
14
commits into
PerryTS:main
Choose a base branch
from
proggeramlug:feat/electron-compat-servo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7ea3e2a
feat(electron): Electron-compatible app shell — run existing Electron…
f602810
fix(compile): warm auto-optimize cache dropped CPU-only well-known li…
0680d08
feat(electron): wire clipboard, Tray, nativeImage, Menu, dialog, acti…
ed43488
fix(electron): address review — dialog root leak, visible-window acti…
8580a00
Merge branch 'feat/electron-shim-native-apis' into feat/electron-comp…
f0c4cc8
feat(servo): unblock in-process Servo — fork servo-script onto ml-kem…
7017923
feat(servo): ServoEngine backend for the WebView widget (PERRY_WEBVIE…
9816885
feat(servo): perry compile --webview=servo selects the Servo UI backend
32953d4
feat(servo): input + resize for the Servo WebView (PerryServoView)
adc1721
style: rustfmt electron-merge artifacts (init.rs, runtime/lib.rs)
7a97670
build(servo): host servo-script fork as a git patch (PerryTS/servo-sc…
0691d7c
Merge remote-tracking branch 'origin/main' into pr5811
59cd330
ci(security-audit): ignore RUSTSEC-2025-0144 (ml-dsa timing side-chan…
a6ecfce
Merge main into feat/electron-compat-servo
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| //! Top-level UI event-loop takeover. | ||
| //! | ||
| //! A native UI backend (perry-ui-macos, …) can register a blocking event-loop | ||
| //! function. Perry's generated `main` calls [`js_ui_loop_take_over`] once, at | ||
| //! the true top level (right before the normal async event loop), so the UI | ||
| //! backend's `[NSApp run]` becomes the outermost loop on the main thread. | ||
| //! | ||
| //! Why this matters: if the UI loop is entered from a microtask / the post-main | ||
| //! drain instead (e.g. `Promise.resolve().then(() => appRunLoop())`), the macOS | ||
| //! window server never composites the app's windows (they exist but report | ||
| //! `onscreen=None`). Entering it at the top level — the same context as the | ||
| //! classic blocking `App({...})` call — fixes that. Used by the Electron-compat | ||
| //! `app.whenReady()` shell, which can't itself block at the top level because it | ||
| //! must first let the user's `main` register `ipcMain`/`whenReady` handlers. | ||
|
|
||
| use std::sync::atomic::{AtomicPtr, Ordering}; | ||
|
|
||
| static UI_LOOP_FN: AtomicPtr<()> = AtomicPtr::new(std::ptr::null_mut()); | ||
|
|
||
| /// Register a blocking UI event-loop entry point. The UI backend calls this | ||
| /// (indirectly, when the program requests a windowed loop) so that | ||
| /// [`js_ui_loop_take_over`] can hand control to it. Passing a null-equivalent | ||
| /// is not expected; registration is one-shot for the process lifetime. | ||
| #[no_mangle] | ||
| pub extern "C" fn perry_runtime_register_ui_loop(f: extern "C" fn()) { | ||
| UI_LOOP_FN.store(f as *mut (), Ordering::SeqCst); | ||
| } | ||
|
|
||
| /// Called once by generated `main` at the top level, just before the normal | ||
| /// async event loop. If a UI loop was registered (a windowed app requested it), | ||
| /// this blocks in that loop for the lifetime of the app (it returns only if the | ||
| /// UI loop itself returns, which a real app's `[NSApp run]` does not — it exits | ||
| /// via `terminate:`). If nothing registered a UI loop, this is a no-op and the | ||
| /// normal event loop proceeds. | ||
| #[no_mangle] | ||
| pub extern "C" fn js_ui_loop_take_over() { | ||
| let p = UI_LOOP_FN.load(Ordering::SeqCst); | ||
| if !p.is_null() { | ||
| let f: extern "C" fn() = unsafe { std::mem::transmute(p) }; | ||
| f(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Root the deferred
on_readycallback instead of storing it only in TLS.PENDING_APP_LOOP_ON_READYkeeps the JS closure only in athread_local Cell<f64>. That value is not a stack local or a registered GC root, so a GC betweenrequest_app_loopandui_loop_entrycan reclaim the closure beforeapp_run_loopreachesjs_closure_call0. There is already such a gap incrates/perry-codegen/src/codegen/entry.rsLines 745-764: generatedmainstill runs the initial microtask/timer drains andjs_run_stdlib_pumpbeforejs_ui_loop_take_over(). Please move this callback into a GC-rooted slot / runtime handle instead of TLS. Based on learnings, values are only pinned across allocations while they remain directly reachable from a Rust stack local; once they live only in a heap/TLS slot, they need explicit rooting.🤖 Prompt for AI Agents
Source: Learnings