fix(ipc): use v8 object to store callbacks#211
Merged
dsh0416 merged 3 commits intoJun 4, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR refactors the IPC listener implementation to store callback lists inside V8 objects (as a hidden property) instead of keeping Rust-side IpcListenerSet state in the render process handler.
Changes:
- Removed
IpcListenerSet(RustRc<RefCell<Vec<V8Value>>>) and replaced it with V8-backed listener storage on the listener API object. - Added helper functions to build/emit/manage listeners via a
__godotCefListenerCallbacksarray property. - Simplified
OsrRenderProcessHandlerto a stateless unit struct and updated callback invocation routing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| crates/cef_app/src/v8_handlers.rs | Replaces Rust-managed listener sets with V8 object property storage and adds listener management helpers. |
| crates/cef_app/src/render_process.rs | Updates render process wiring to build listener API objects per context and emit via V8-backed listeners. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+245
to
+253
| pub(crate) fn build_ipc_listener_object() -> Option<V8Value> { | ||
| let object = v8_value_create_object(None, None)?; | ||
| let mut callbacks = v8_value_create_array(0)?; | ||
| let callbacks_key: CefStringUtf16 = LISTENER_CALLBACKS_KEY.into(); | ||
| object.set_value_bykey( | ||
| Some(&callbacks_key), | ||
| Some(&mut callbacks), | ||
| v8_prop_default(), | ||
| ); |
Comment on lines
+248
to
+253
| let callbacks_key: CefStringUtf16 = LISTENER_CALLBACKS_KEY.into(); | ||
| object.set_value_bykey( | ||
| Some(&callbacks_key), | ||
| Some(&mut callbacks), | ||
| v8_prop_default(), | ||
| ); |
Comment on lines
+286
to
+292
| fn listener_callbacks(object: &V8Value) -> Option<V8Value> { | ||
| let callbacks_key: CefStringUtf16 = LISTENER_CALLBACKS_KEY.into(); | ||
| object.value_bykey(Some(&callbacks_key)) | ||
| } | ||
|
|
||
| fn collect_listener_callbacks(callbacks: &V8Value) -> Vec<V8Value> { | ||
| let len = callbacks.array_length(); |
Comment on lines
+291
to
+303
| fn collect_listener_callbacks(callbacks: &V8Value) -> Vec<V8Value> { | ||
| let len = callbacks.array_length(); | ||
| let mut snapshot = Vec::with_capacity(len.max(0) as usize); | ||
| for index in 0..len { | ||
| if let Some(callback) = callbacks.value_byindex(index) | ||
| && callback.is_valid() != 0 | ||
| && callback.is_function() != 0 | ||
| { | ||
| snapshot.push(callback); | ||
| } | ||
| } | ||
| snapshot | ||
| } |
Comment on lines
303
to
307
| && callback.is_function() != 0 | ||
| { | ||
| let args = [Some(value.clone())]; | ||
| let _ = callback.execute_function(Some(&mut global), Some(&args)); | ||
| callback.execute_function(Some(&mut global), Some(&args)); | ||
| } |
Owner
|
LGTM. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Avoid callback lost after page navigation.
Checklist