-
Notifications
You must be signed in to change notification settings - Fork 87
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
Fix use of http transport from background isolate #1470
Fix use of http transport from background isolate #1470
Conversation
Pull Request Test Coverage Report for Build 7612377268
💛 - Coveralls |
26d7f81
to
9376ced
Compare
The issues fixed in this PR was introduced with , but was never released, so I didn't update the CHANGELOG. Since Apps are now cached and shared we need to be vigilant to always route to the correct isolate in cases such as Hence we need to ensure all data is available not only when the callback is scheduled, but also when it actually runs. The current realm C-api expects callback to be executed synchronously, so we need to deep-copy all non-value arguments and handle lifetime explicitly. This involves a bit of simple and dumb native code, such as: RLM_API void realm_dart_user_completion_callback(realm_userdata_t userdata, realm_user_t* user, const realm_app_error_t* error)
{
// we need to make a deep copy of error, because the message pointer points to stack memory
auto error_copy = realm_app_error_copy(error);
// take an extra ref to the user, so that it doesn't get deleted before we invoke the callback
std::shared_ptr<realm::SyncUser> user_copy;
if (user != nullptr) {
user_copy = realm_user(*user);
}
auto ud = reinterpret_cast<realm_dart_userdata_async_t>(userdata);
ud->scheduler->invoke([ud, error = std::move(error_copy), user = realm_user(user_copy)]() mutable {
(reinterpret_cast<realm_app_user_completion_func_t>(ud->dart_callback))(ud->handle, &user, error.get());
});
} Going forward we could:
BTW: Note that (unrelated to the fix) the Dart native interface has been bumped to 2.2, which is backwards compatible with 2.0 that we used previously. |
880329d
to
501d614
Compare
015fc7e
to
2c0de6c
Compare
… survive until needed during async callback
8df35e1
to
453fe79
Compare
After the introduction of realm app caching hot-restart and background isolates no longer works reliably with realm.
Fixes: #1467
Fixes: #1466
Fixes: #1451
Fixes: #1433 (only half fixed by #1445)