Skip to content
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

Fixing chrome debugging on v10 #3411

Merged
merged 18 commits into from
Dec 4, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ RPCServer::RPCServer() {

// Enable the RCP network transport to issue calls to the remote fetch function
jsc::Types::Function fetch_function = Value::validated_to_function(m_context, deserialize_json_value(dict["fetch"]), "fetch");
RPCNetworkTransport::fetch_function = js::Protected<jsc::Types::Function>(m_context, fetch_function);
RPCNetworkTransport::fetch_function = js::Protected(m_context, fetch_function);

m_session_id = store_object(realm_constructor);
return (json){{"result", m_session_id}};
Expand Down Expand Up @@ -624,6 +624,9 @@ RPCServer::~RPCServer() {
m_objects.clear();
m_callbacks.clear();

// Clear the Object Store App cache, to prevent instances from using the context which is going to be released.
app::App::clear_cached_apps();
Copy link
Member Author

Choose a reason for hiding this comment

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

I am a bit unsure if this is the right place to call it.
I'm unaware of another place in our code that gets called when we're "unloading" our library, but we could clear the object store app cache when we initialize instead? https://github.com/realm/realm-js/blob/master/src/jsc/jsc_init.cpp#L42

Copy link
Member Author

Choose a reason for hiding this comment

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

@blagoev @kneth ☝️ what do you think about that?

Copy link
Contributor

Choose a reason for hiding this comment

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

I imagine the issue is when you reload the app, right? If so, I think it make sense to clear the cache as you shut down the RPC server.

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct. If it's not cleared before / after a reload object store might be reusing app instances that reference a context which has been garbage collected.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍


get_rpc_server(m_context) = nullptr;
JSGlobalContextRelease(m_context);
}
Expand Down