-
Notifications
You must be signed in to change notification settings - Fork 165
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
Realm crashes when app is in the background #5731
Comments
Thank you for reporting. I have a couple of questions:
If you only observe it on iOS, I am very interested to know if enabling background tasks will solve the issue? Unfortunately it is difficult to apply the trick from Realm Swift, but we are considering to add a configuration option to relax the protection level. |
Thank you for your response.
Couple of things I want to clarify as well:
I will try the Realm Swift trick and let you know if that fixes the issue. |
This is similar to the stack trace in #5435. I suspect there is an issue in the network code. Any further information about how to reproduce this would be very valuable. @iprabin since you are able to reproduce this in debug mode, can you check the console output for the assertion failure message and provide it here? |
When investigating realm/realm-js#4525 we tried to simulate the above (the reporter's app is similar to what you describe). Unfortunately we were never to provoke a crash. We didn't implement the Realm Swift trick as it highly speculative without a reproduction case. If the trick improves the situation for you, we can implement it in Realm JavaScript and document when to use it. |
@iprabin Did you have a chance to try the Realm Swift trick? If so, did it improve the stability of the app? |
@kneth, I did implement the realm swift trick and i am not able to reproduce the crash anymore. I will let you know if anything else changes in the next couple of weeks. For now, I will close the issue as well. Thank you for your help. |
@iprabin Great news. Can I get you to describe what you did? I mean, which files did you modify, etc. It will be valuable for the next app developer who runs into the same problem. |
@kneth I am modifying the whole directory created by realm when we first open realm sync. We no longer have the crash even when the app is running in the background for over half of the day. Here is the swift code:
Here is the react-native code:
|
SDK and version
SDK : realm-js
Version: 10.19.5
Observations
The crash is happening on background after 15 mins
Dev
Yes
Start realm sync when app is launched. We generate some data and start inserting data into realm. We put the app in the background and lock the phone. After 15 mins, bring the app into foreground and it will crash.
Crash log / stacktrace
0 libsystem_kernel.dylib 0x00000001cc438334 __pthread_kill + 8 (:-1)
1 libsystem_pthread.dylib 0x00000001e9ebda9c pthread_kill + 272 (pthread.c:1582)
2 libsystem_c.dylib 0x00000001a74a9b84 abort + 124 (abort.c:118)
3 AppName 0x0000000100d61684 please_report_this_issue_in_github_realm_realm_core + 12
4 AppName 0x0000000100d6196c realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits, std::__1::allocator >&) + 260
5 AppName 0x0000000100d617cc realm::util::terminate(char const*, char const*, long, std::initializer_listrealm::util::Printable&&) + 328
6 AppName 0x0000000100c1c664 realm::util::network::Service::BasicStreamOpsrealm::util::network::ssl::Stream::BufferedReadOperBase::advance() + 336
7 AppName 0x0000000100c1c078 void realm::util::network::Service::BasicStreamOpsrealm::util::network::ssl::Stream::async_buffered_read<realm::util::UniqueFunction<void (std::__1::error_code, unsigned long)> >(realm::util::net... + 88
8 AppName 0x0000000100c179dc realm::util::websocket::(anonymous namespace)::EZSocketImpl::async_read(char*, unsigned long, realm::util::UniqueFunction<void (std::__1::error_code, unsigned long)>) + 72
9 AppName 0x0000000100c28650 (anonymous namespace)::WebSocket::frame_reader_loop() + 1140
10 AppName 0x0000000100c1c818 void realm::util::network::Service::AsyncOper::do_recycle_and_execute<realm::util::UniqueFunction<void (std::__1::error_code, unsigned long)>, std::__1::error_code&, unsigned long&>(bool, realm::ut... + 148
11 AppName 0x0000000100c1c394 realm::util::network::Service::BasicStreamOpsrealm::util::network::ssl::Stream::BufferedReadOper<realm::util::UniqueFunction<void (std::__1::error_code, unsigned long)> >::recycle_and_execute() + 240
12 AppName 0x0000000100c1f250 realm::util::network::Service::Impl::run() + 456
13 AppName 0x0000000100ba3b94 realm::sync::Client::run() + 36
14 AppName 0x0000000100aeed2c void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_deletestd::__1::__thread_struct >, realm::_impl::SyncClient::SyncClient(std::__1::... + 44
15 libsystem_pthread.dylib 0x00000001e9ebcbfc _pthread_start + 320 (pthread.c:887)
16 libsystem_pthread.dylib 0x00000001e9ec5758 thread_start + 8 (:-1)
Code Sample
Open realm sync with config
try { realm = await Realm.open(config); } catch (e) { console.log(e); }
Writing to realm
realm.write(() => { realm.create("data", { sensor: { timestamp: data.timestamp, values: data.values, frequency: data.freq, }, partitionId:partitionId, timestamp: new Date(), userId: user.id, _id: new ObjectId(), });
The text was updated successfully, but these errors were encountered: