Skip to content

fix(ipc): use v8 object to store callbacks#211

Merged
dsh0416 merged 3 commits into
dsh0416:mainfrom
LemonNekoGH:lemonnekogh/callback-lost-after-navigation
Jun 4, 2026
Merged

fix(ipc): use v8 object to store callbacks#211
dsh0416 merged 3 commits into
dsh0416:mainfrom
LemonNekoGH:lemonnekogh/callback-lost-after-navigation

Conversation

@LemonNekoGH

Copy link
Copy Markdown
Contributor

Description

Avoid callback lost after page navigation.

Checklist

  • I tested my changes locally
  • I updated docs/tests if needed
  • CI passes (or I explained why it does not)

Copilot AI review requested due to automatic review settings June 1, 2026 12:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (Rust Rc<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 __godotCefListenerCallbacks array property.
  • Simplified OsrRenderProcessHandler to 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 thread crates/cef_app/src/v8_handlers.rs Outdated
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 thread crates/cef_app/src/v8_handlers.rs Outdated
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));
}
@dsh0416

dsh0416 commented Jun 4, 2026

Copy link
Copy Markdown
Owner

LGTM.

@dsh0416 dsh0416 merged commit 062bb03 into dsh0416:main Jun 4, 2026
19 checks passed
@LemonNekoGH LemonNekoGH deleted the lemonnekogh/callback-lost-after-navigation branch June 4, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants