Missing Collection notifications
See original GitHub issueWe have huge problems on CI with tests timing out with what looks like notifications being skipped. I was able to somewhat reproduce it locally, but it looks very timing dependant and @beeender has not been able to verify on his machine:
Reproduce
- Install ROS locally
npm install -g realm-object-server@rc - Disable
startSyncServer/stopSyncServerinStandardIntegrationTestclass - Run
PermissionManagerTests#getPermissions_updatedWithNewRealmsonce from Android Studio to install test app on the device and see that it runs green - Goto commandline and run I’m running this script:
#!/bin/bash
adb shell am instrument -w -r -e debug false -e class io.realm.PermissionManagerTests#getPermissions_updatedWithNewRealms io.realm.test/android.support.test.runner.AndroidJUnitRunner
while [ $? -eq 0 ]; do
adb shell am instrument -w -r -e debug false -e class io.realm.PermissionManagerTests#getPermissions_updatedWithNewRealms io.realm.test/android.support.test.runner.AndroidJUnitRunner
done
with
while ./test.sh; do :; done
- Prepare to wait for a while. ROS might eventually run out of filedescriptors on Mac, in that case, restart server and script
- When the bug is caught, the test will timeout and show the below output. The log statements probably doesn’t make much sense, but the important ones are the
before_advanceandafter_advancewhich is used to trigger notifications.
This is the code in after_advance:
void CollectionNotifier::after_advance()
{
__android_log_print(ANDROID_LOG_ERROR, "OS", "After advance: Size %d", m_callbacks.size());
for_each_callback([&](auto& lock, auto& callback) {
if (callback.initial_delivered && callback.changes_to_deliver.empty()) {
__android_log_print(ANDROID_LOG_ERROR, "OS", "After advance: Ignore callback (%s, %s)", callback.initial_delivered?"true":"false", callback.changes_to_deliver.empty()?"true":"false");
return;
}
callback.initial_delivered = true;
auto changes = std::move(callback.changes_to_deliver);
// acquire a local reference to the callback so that removing the
// callback from within it can't result in a dangling pointer
auto cb = callback.fn;
lock.unlock();
__android_log_print(ANDROID_LOG_ERROR, "OS", "After advance: Trigger callback (%s, %s)", callback.initial_delivered?"true":"false", callback.changes_to_deliver.empty()?"true":"false");
cb.after(changes);
});
}
Logs
Successfull attempt
10-12 10:02:45.266 8690-8709/? E/OS: Add callback
10-12 10:02:45.267 8690-8709/? E/OS: After advance: Size 1
10-12 10:02:45.267 8690-8709/? E/OS: After advance: Trigger callback (true, true)
10-12 10:02:45.268 8690-8709/? E/REALM_JAVA: Size: 2, State: ACTIVE
10-12 10:02:45.268 8690-8709/? E/OS: Remove callback
10-12 10:02:45.320 8690-8709/? E/OS: Add callback
10-12 10:02:45.321 8690-8709/? E/OS: After advance: Trigger callback (true, true)
10-12 10:02:45.321 8690-8709/? E/OS: After advance: Size 1
10-12 10:02:45.321 8690-8709/? E/OS: After advance: Ignore callback (true, true) <!--
10-12 10:02:45.321 8690-8709/? E/OS: After advance: Size 0
10-12 10:02:45.333 8690-8709/? E/OS: Before advance: Size 1
10-12 10:02:45.333 8690-8709/? E/OS: Before advance: Size 0
10-12 10:02:45.333 8690-8709/? E/OS: After advance: Size 1
10-12 10:02:45.334 8690-8709/? E/OS: After advance: Trigger callback (true, true)
10-12 10:02:45.336 8690-8709/? E/REALM_JAVA: Testlistener: 3
10-12 10:02:45.338 8690-8709/? E/OS: After advance: Size 0
Failed attemp:
10-12 10:09:37.937 13397-13416/? E/OS: Add callback
10-12 10:09:37.937 13397-13416/? E/OS: After advance: Size 1
10-12 10:09:37.937 13397-13416/? E/OS: After advance: Trigger callback (true, true)
10-12 10:09:37.938 13397-13416/? E/REALM_JAVA: Size: 2, State: ACTIVE
10-12 10:09:37.938 13397-13416/? E/OS: Remove callback
10-12 10:09:37.988 13397-13416/? E/OS: Add callback
10-12 10:09:37.988 13397-13416/? E/OS: After advance: Trigger callback (true, true)
10-12 10:09:37.988 13397-13416/? E/OS: Before advance: Size 1
10-12 10:09:37.988 13397-13416/? E/OS: Before advance: Size 0
10-12 10:09:37.989 13397-13416/? E/OS: After advance: Size 1
10-12 10:09:37.989 13397-13416/? E/OS: After advance: Ignore callback (true, true) <!-- Did it move here?
10-12 10:09:37.989 13397-13416/? E/OS: After advance: Size 0
<!-- Test times out here
10-12 10:09:38.991 13397-13416/io.realm.test E/REALM_JAVA: Real size: 3 <!-- Opening the Realm on another thread verified that the change is in the DB
I have narrowed it down to https://github.com/realm/realm-object-store/blob/master/src/impl/collection_notifier.cpp#L326 but I have no explanation as to why it is happening:
Open questions:
after_advanceis called twice. It is unclear why. Probably because twoResultsexist, but it doesn’t look like I create two. Conclussion: Doesn’t look related- When failing, it looks like code inside the callback isn’t triggered. Add more logging to verify how far it gets. Conclussion: Done, see https://github.com/realm/realm-java/issues/5413#issuecomment-336212117
- https://github.com/realm/realm-java/issues/5411 did not catch this
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
Use notifications on your iPhone or iPad - Apple Support
Open from Notification Center. Notification Center shows your notifications history, allowing you to scroll back and see what you've missed.
Read more >Missed Notifications Reminder - Apps on Google Play
Unfortunately Android doesn't have default integrated functionality to notify user periodically about missing calls/messages/other notifications via sound ...
Read more >Set Beep Alerts to Warn You of Missed Messages « Android
To do that, tap the "Manage Access" button, enable the Missed Notification Reminder entry on the following screen, and press "Allow" on the ......
Read more >Create an alert to get notified when a file or folder changes in ...
See how to create and manage alerts to stay updated when SharePoint libraries, lists, documents, or items on your site change.
Read more >Change email notifications - Android - Gmail Help
Note: If you're using Android O and above, tap Manage notifications. Under your account, make sure the switch is set to On. Choose...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I think
process_available_syncis a typo forprocess_available_async?Folding this into #5507 We have reports from multiple developers that point to notifications sometimes being skipped, this is another datapoint