-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Crash When Application Terminates in realm::util::set_termination_notification_callback #4028
Comments
I like to believe this isn't affecting our end users because it's happening when the app terminates and is therefore theoretically backgrounded, but at the same time it's a nontrivial hit to our crash-free rate in Fabric and generates noise for us to sift through. |
@LeffelMania, in the past we've seen similar errors when an application exits while a thread is actively writing to a Realm. The Fabric link you provided only shows the crash log for a single instance of the crash so it's difficult to tell one way or another if this is what is happening here. Does this seem like something your app could be doing? Do you have access to more than the single crash log I can see? |
@bdash I'm not sure I can get you access to the full set of crash reports, but that definitely sounds like something that can happen with our app. Other instances of the crash I'm able to view do seem to be writing on other threads when this occurs. Other thread activity from another report:
Thread 8
Thread 11
So I feel like that's probably the issue. Is there a clean way to tell Realm "Stop whatever you're doing on all threads right now" in our |
Hi @bdash @mrackwitz |
In order to avoid this crash, I think you'd need to ensure that none of your background threads have open write transactions when the app is exiting. This isn't something that Realm can do for you as we have no knowledge of what your threads are up to, or whether it's safe to interrupt them. One thing we may be able to do is make it safe to exit while a Realm transaction is in progress. I've written up realm/realm-core#2137 to track doing that. This would result in the write transaction being canceled, so depending on your app's need you might still need to avoid having open write transactions when your app is terminating. |
This was fixed in #4261. |
Goals
Gracefully handle the system terminating our application.
Expected Results
System terminates our application peacefully.
Actual Results
We have a frequent crash reported in Fabric that Realm crashes in its termination handler.
Raw trace:
Steps to Reproduce
No repro steps unfortunately. All of our breadcrumbs for this crash end with us logging a call to
applicationWillTerminate:
, which is our last line of code in that function.Code Sample
N/A
Version of Realm and Tooling
The text was updated successfully, but these errors were encountered: