-
Notifications
You must be signed in to change notification settings - Fork 370
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
[Bug]: Fatal Exception: java.util.ConcurrentModificationException #1857
Comments
Thanks for the report, @ayushi-sk. We're investigating this along with the similar crash you reported. |
Here is also another crash report:
|
More stack traces of this error happening in different places from within onesignal.core:
|
Hi all, I apologize for any delay, We have identified the cause and are working on the fix for all the methods this crash is reported. |
Seems like the same issue, but sharing my stack trace on 5.0.3 in case it's helpful
|
Spotted one other instance of the same issue:
|
I've found a way to consistently reproduce this issue:
import { OneSignal } from 'react-native-onesignal'; // V5
function requestNotificationsPermission() {
OneSignal.Notifications.canRequestPermission().then(async (canRequest) => {
canRequest && OneSignal.Notifications.requestPermission(false); // If notifications permission was already denied, this will be resolved immediately
});
}
// Two or more parallel calls will reproduce the crash
requestNotificationsPermission();
requestNotificationsPermission(); It seems the On OneSignal's side, the fix would be to make the store safe for concurrent changes (e.g. Datastore), as it's recommended for stores with read/write based on events. A simple, but temporary, fix on our side would be to implement notification permissions somewhat like this: function useManageOneSignalPermissions() {
const loading = useRef(false);
useEffect(
function checkForNotificationPermissions() {
// Requesting permission more than once, simultaneously causes a crash on Android if the user has denied Notification Permissions
if (!loading.current) {
loading.current = true;
OneSignal.Notifications.canRequestPermission()
.then(async (canRequest) => {
canRequest && await OneSignal.Notifications.requestPermission(false);
})
.finally(() => {
loading.current = false
});
}
},
[]
)
} I came up with this fix while thinking about how this error sounded familiar, which reminded me of a similar error I'd fixed over react-native-iap, which also turned out to be due to a racing condition triggered by parallel async calls; So I started searching for async calls in onesig and figured out that the notification permission's methods were causing this exception. |
adding to the list |
The crashes keep coming, Xiaomi Xiaomi 11 T Android 13:
|
Hello everyone! Thank you for your patience here. We have introduced a fix for this crash in our latest release, 5.0.4. Please update your SDK and let us know if you are still having any issues. |
Closing out this issue. Please let us know if you are seeing any further occurrences of this exception. Thanks! |
What happened?
Steps to reproduce?
What did you expect to happen?
Not crash the app
OneSignal Android SDK version
5.0.2
Android version
11, 10
Specific Android models
No response
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: