[Bug]: Serialization error when opening app via a notification
What happened?
I'm suddenly getting this error on IOS when I build from Unity. This error occurs when I open the app by tapping on a notification, it works fine on Android. I'm using the latest version of the onesignal sdk for unity. (3.0.2)
Steps to reproduce?
Send a push notification with additional data, we use this code in Unity:
var notification = new Dictionary<string, object>();
string localUserName = _localUser.Name;
if (string.IsNullOrEmpty(localUserName))
{
localUserName = _localUser.username;
}
notification["contents"] = new Dictionary<string, string>() { { "en", messageToSend } };
notification["headings"] = new Dictionary<string, string>() { { "en", "Message from " + localUserName } };
notification["include_player_ids"] = new List<string>() { friendPushID };
notification["data"] = new Dictionary<string, string>() { { "senderID", _localUser.ID } };
var response = await OneSignal.Default.PostNotification(notification);
What did you expect to happen?
When the app is opened via a notification it should call the function: OneSignal.Default.NotificationOpened += OneSignalOnNotificationOpened;
This works on Android builds and used to work on iOS but recently stopped working, perhaps after the update to the 3.0.2 sdk, but we're not sure.
Unity version
2021.3.2
OneSignal Unity SDK version
3.0.2
Platform
iOS
Relevant log output
Serialization depth limit 10 exceeded at 'OneSignalSDK::Notification.actionButtons'. There may be an object composition cycle in one or more of your serialized classes.
Serialization hierarchy:
11: OneSignalSDK::Notification.actionButtons
10: OneSignalSDK::Notification.groupedNotifications
9: OneSignalSDK::Notification.groupedNotifications
8: OneSignalSDK::Notification.groupedNotifications
7: OneSignalSDK::Notification.groupedNotifications
6: OneSignalSDK::Notification.groupedNotifications
5: OneSignalSDK::Notification.groupedNotifications
4: OneSignalSDK::Notification.groupedNotifications
3: OneSignalSDK::Notification.groupedNotifications
2: OneSignalSDK::Notification.groupedNotifications
1: OneSignalSDK::Notification.groupedNotifications
0: OneSignalSDK::Notification.groupedNotifications
UnityEngine.JsonUtility:FromJson(String)
OneSignalSDK.OneSignalIOS:_onNotificationOpened(String)
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Thanks for reporting your issue. Are you using emojis in your notification, like in your messageToSend variable? Currently, the parser we use does not support emoji and we are looking to resolve this.
If not, could you please increase your logging level by calling
OneSignal.Default.LogLevel = LogLevel.Info;
OneSignal.Default.AlertLevel = LogLevel.Fatal;
early in your application's lifecycle such as in the Start() method of a MonoBehaviour in your opening Scene and provide the log.
If you are allowed to, could you also provide the contents of the notification payload?
Hi, thanks for the reply. Our message to send is usually something like: "Have a good day!"
No, we don't have emojis.
Also, I've tried to send a push to myself on iOS using the Onesignal dashboard to send to a test user with the message text "test" and this for the additional data: https://share.getcloudapp.com/9ZuoKBbL
And it fails with the same errors as I listed above. So I don't think it's related to our sending code or the actual text we are sending.
Thanks for the update. I'm sorry but I haven't been able to reproduce your issue. Could you provide a log with an increased log level?
Oh I thought that this was a known issue based on the Discord channel comments, otherwise I wouldn't have waited for a month to get help... ok well, here's the log anyways:
Serialization depth limit 10 exceeded at 'OneSignalSDK::Notification.actionButtons'. There may be an object composition cycle in one or more of your serialized classes.
Serialization hierarchy: 11: OneSignalSDK::Notification.actionButtons 10: OneSignalSDK::Notification.groupedNotifications 9: OneSignalSDK::Notification.groupedNotifications 8: OneSignalSDK::Notification.groupedNotifications 7: OneSignalSDK::Notification.groupedNotifications 6: OneSignalSDK::Notification.groupedNotifications 5: OneSignalSDK::Notification.groupedNotifications 4: OneSignalSDK::Notification.groupedNotifications 3: OneSignalSDK::Notification.groupedNotifications 2: OneSignalSDK::Notification.groupedNotifications 1: OneSignalSDK::Notification.groupedNotifications 0: OneSignalSDK::NotificationOpenedResult.notification UnityEngine.JsonUtility:FromJson(String) OneSignalSDK.OneSignalIOS:_onNotificationOpened(String)
[ line 1833708616]
Serialization depth limit 10 exceeded at 'OneSignalSDK::Notification.actionButtons'. There may be an object composition cycle in one or more of your serialized classes.
Serialization hierarchy: 11: OneSignalSDK::Notification.actionButtons 10: OneSignalSDK::Notification.groupedNotifications 9: OneSignalSDK::Notification.groupedNotifications 8: OneSignalSDK::Notification.groupedNotifications 7: OneSignalSDK::Notification.groupedNotifications 6: OneSignalSDK::Notification.groupedNotifications 5: OneSignalSDK::Notification.groupedNotifications 4: OneSignalSDK::Notification.groupedNotifications 3: OneSignalSDK::Notification.groupedNotifications 2: OneSignalSDK::Notification.groupedNotifications 1: OneSignalSDK::Notification.groupedNotifications 0: OneSignalSDK::Notification.groupedNotifications UnityEngine.JsonUtility:FromJson(String) OneSignalSDK.OneSignalIOS:_onNotificationOpened(String)
[ line 1833707240]
2022-07-19 18:42:06.378129+0200 Bonu[62763:4743615] Request <OSRequestOnFocus: 0x281b9c510> success result { id = "dc2e0b82-b5fa-11ec-b5de-000000000000"; success = 1; } -> applicationDidBecomeActive() getting friends DatabaseAPI.Account.AccountManager:GetFriends(Action) DatabaseAPI.Account.AccountManager:OnApplicationFocus(Boolean)
2022-07-19 18:42:06.795947+0200 Bonu[62763:4743615] [Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service with pid 93 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service with pid 93 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.} 2022-07-19 18:42:06.955235+0200 Bonu[62763:4743615] Request <OSRequestRegisterUser: 0x281b940f0> success result { id = "dc2e0b82-b5fa-11ec-b5de-000000000000"; success = 1; }
and here's onesignal related messages earlier in the log: [OneSignal] OneSignal.Default set to platform SDK OneSignalSDK.OneSignalIOS. Current version is 3.0.0 OneSignalSDK.OneSignal:set_Default(OneSignal)
(this is incorrect, the version is 3.0.2.. I don't know if the log just hasn't been updated)
[User Defaults] Couldn't read values in CFPrefsPlistSource<0x283a51880> (Domain: group.com.mcg.Bonu.onesignal, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd CrashReporter: initialized
@capitaljmedia For the notification open handler not firing on iOS I believe this is the same issue as #511. Can try placing your OneSignal.Default.NotificationOpened += OneSignalOnNotificationOpened; handler before you call OneSignal.Initialize?
Tried that, same issue:
Serialization depth limit 10 exceeded at 'OneSignalSDK::Notification.actionButtons'. There may be an object composition cycle in one or more of your serialized classes.
Serialization hierarchy: 11: OneSignalSDK::Notification.actionButtons 10: OneSignalSDK::Notification.groupedNotifications 9: OneSignalSDK::Notification.groupedNotifications 8: OneSignalSDK::Notification.groupedNotifications 7: OneSignalSDK::Notification.groupedNotifications 6: OneSignalSDK::Notification.groupedNotifications 5: OneSignalSDK::Notification.groupedNotifications 4: OneSignalSDK::Notification.groupedNotifications 3: OneSignalSDK::Notification.groupedNotifications 2: OneSignalSDK::Notification.groupedNotifications 1: OneSignalSDK::Notification.groupedNotifications 0: OneSignalSDK::NotificationOpenedResult.notification UnityEngine.JsonUtility:FromJson(String) OneSignalSDK.OneSignalIOS:_onNotificationOpened(String)
[ line 1800612936]
2022-07-20 15:21:49.819599+0200 Bonu[70203:5244103] [connection] nw_read_request_report [C6] Receive failed with error "Software caused connection abort" Serialization depth limit 10 exceeded at 'OneSignalSDK::Notification.actionButtons'. There may be an object composition cycle in one or more of your serialized classes.
Serialization hierarchy: 11: OneSignalSDK::Notification.actionButtons 10: OneSignalSDK::Notification.groupedNotifications 9: OneSignalSDK::Notification.groupedNotifications 8: OneSignalSDK::Notification.groupedNotifications 7: OneSignalSDK::Notification.groupedNotifications 6: OneSignalSDK::Notification.groupedNotifications 5: OneSignalSDK::Notification.groupedNotifications 4: OneSignalSDK::Notification.groupedNotifications 3: OneSignalSDK::Notification.groupedNotifications 2: OneSignalSDK::Notification.groupedNotifications 1: OneSignalSDK::Notification.groupedNotifications 0: OneSignalSDK::Notification.groupedNotifications UnityEngine.JsonUtility:FromJson(String) OneSignalSDK.OneSignalIOS:_onNotificationOpened(String)
[ line 1800611560]
2022-07-20 15:21:49.820150+0200 Bonju[70203:5244103] [connection] nw_read_request_report [C4] Receive failed with error "Software caused connection abort" 2022-07-20 15:21:49.821050+0200 Bonju[70203:5244103] [connection] nw_read_request_report [C1] Receive failed with error "Software caused connection abort" 2022-07-20 15:21:49.821222+0200 Bonju[70203:5244103] [connection] nw_read_request_report [C3] Receive failed with error "Software caused connection abort" 2022-07-20 15:21:49.822482+0200 Bonju[70203:5244103] [connection] nw_read_request_report [C5] Receive failed with error "Software caused connection abort" 2022-07-20 15:21:49.822643+0200 Bonju[70203:5244103] [connection] nw_read_request_report [C2] Receive failed with error "Software caused connection abort" 2022-07-20 15:21:49.828267+0200 Bonju[70203:5244954] Task <3B93CC2D-5AA1-4593-BC97-8FFC80C53992>.<3> HTTP load failed, 65/0 bytes (error code: -1005 [1:53]) 2022-07-20 15:21:49.828391+0200 Bonju[70203:5244122] Task <6EFA4750-F07B-4EE9-A9DB-0842FCE18C5A>.<4> HTTP load failed, 62/0 bytes (error code: -1005 [1:53]) 2022-07-20 15:21:49.831736+0200 Bonju[70203:5244124] Task <3B93CC2D-5AA1-4593-BC97-8FFC80C53992>.<3> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=53, NSUnderlyingError=0x282eaf420 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={_kCFStreamErrorCodeKey=53, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <3B93CC2D-5AA1-4593-BC97-8FFC80C53992>.<3>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <3B93CC2D-5AA1-4593-BC97-8FFC80C53992>.<3>" ), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://api.onesignal.com/notifications/102cbbf9-20cb-4762-808c-569c3f1626f2, NSErrorFailingURLKey=https://api.onesignal.com/notifications/102cbbf9-20cb-4762-808c-569c3f1626f2, _kCFStreamErrorDomainKey=1} 2022-07-20 15:21:49.831901+0200 Bonju[70203:5244124] Task <6EFA4750-F07B-4EE9-A9DB-0842FCE18C5A>.<4> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=53, NSUnderlyingError=0x282ea5f20 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={_kCFStreamErrorCodeKey=53, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <6EFA4750-F07B-4EE9-A9DB-0842FCE18C5A>.<4>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <6EFA4750-F07B-4EE9-A9DB-0842FCE18C5A>.<4>" ), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://api.onesignal.com/players/dc2e0b82-b5fa-11ec-b5de-000000000000/on_focus, NSErrorFailingURLKey=https://api.onesignal.com/players/dc2e0b82-b5fa-11ec-b5de-000000000000/on_focus, _kCFStreamErrorDomainKey=1} -> applicationDidBecomeActive() getting friends DatabaseAPI.Account.AccountManager:GetFriends(Action) DatabaseAPI.Account.AccountManager:OnApplicationFocus(Boolean)
I tried but I still couldn't reproduce your issue with the notification on opened handler not being fired. Could you provide a step by step process a user goes through to make the issue occur on your app? Correct me if I'm wrong but, is this what happens?
- User is subscribed to your app and can receive notifications
- User receives a notification while the app is not open
- User clicks the on the notification and it opens the app
- App is opened and the
OneSignalOnNotificationOpenedhandler is set up and thenOneSignal.Initializeis called OneSignalOnNotificationOpenedcallback does not occur
If you have the time, could you try to reproduce the issue in a new Unity project or in the OneSignal Unity SDK Example Project that you could then share with us?
Hello, checking in. Are you still having this issue?
Feel free to reply and reopen this issue if you are still experiencing this problem
Hi there, I have the exact same issue, with the same output that the depth exceeded for grouped notifications. I call OneSignal.Default.NotificationWillShow += onNotificationWillShow; before initializing. This is Unity 2021.3.9f1 and OneSignal SDK 3.0.4 EDIT: this is on iOS EDIT2: This is also on Android, and on both platforms it doesn't need to be a grouped notification.
I had this issue and isolated it to the following:
void Start()
{
OneSignal.Default.Initialize("secrets");
OneSignal.Default.NotificationOpened += OnNotificationOpened;
}
And
void OnNotificationOpened(NotificationOpenedResult result)
{
var notif = result.notification;
var action = result.action;
object type;
object id;
result.notification.additionalData.TryGetValue("type", out type);
result.notification.additionalData.TryGetValue("id", out id);
_dataType = type.ToString();
//_dataId = (int)id;
Debug.Log($"OnNotificationOpened type: {type.ToString()} id: {id.ToString()}");
}
If I uncomment the line: _dataId = (int)id; then the following error occurs:
Serialization depth limit 10 exceeded at 'OneSignalSDK::Notification.actionButtons'. There may be an object composition cycle in one or more of your serialized classes.
So, there is no problem if I convert the data to to string like _dataType = type.ToString(); but if I force the data into an int, the problem happens every time.
We believe that The Serialization depth limit 10 exceeded at 'OneSignalSDK::Notification.actionButtons'. … is only a warning log.
There is a Unity forum post which describes the Unity serialization/deserialization process here. In our case, the payload being deserialized will never hit the limit.
@seanbiganski Are you experiencing any other issues beyond seeing this in the log?
@shepherd-l Yes, the app would actually freeze if I tried to force the value into an int. Storing the value in a string and later converting it to an int for my purposes worked fine.