-
Notifications
You must be signed in to change notification settings - Fork 16
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
Clear iOS platform instances synchronously #249
Conversation
dispatch_async
dispatch_async
)
Here is an explanation of the existing buggy code: When a users application (or example app) launches for the first time, or a hot restart happens (Flutter app restarts without restarting iOS host application), the Dart side calls a method: Bug: The for (ARTRealtime *const r in _realtimeInstances.allValues) {
[r close];
}
[_realtimeInstances removeAllObjects];
[_restInstances removeAllObjects]; deleting the users realtime client, when they didn't intend for it to be deleted. |
…ful. It is only resetting instances
…emove-background-queue
dispatch_async
)
I'm moving this code from running in the background, to instead run synchronously.
This fixes a race condition bug where dispose is first called from the Dart side to clear all the instances of realtime and rest. At this point, the realtime/rest clients are not yet cleared, and the work is queued. The actual implementation of
dispose
might only happen afterwards, because ofdispatch_async
. By that time, a user might have created a new realtime instance. Then, this dispose method finally gets called, and their client is deleted, after they create it.This was actually discovered because I removed the button
create realtime
, and created the realtime client on launch instead. User applications would likely create a realtime instance either on application launch or user log in too.Having said that, adding buttons for closing realtime and re-creating it can be useful to debug issues.