NIFCLOUD-mbaas / UserCommunity

ニフクラ mobile backend ユーザーコミュニティ
https://mbaas.nifcloud.com/
81 stars 18 forks source link

[Unity]ゲーム起動時にNCMBUser.CurrentUserを取得する際「stack overflow」のエラーが発生します。 #1344

Closed akiaki2020 closed 1 year ago

akiaki2020 commented 1 year ago

現在開発中のゲームで以下問題が発生してます。

①匿名ユーザーで認証しログアウトせずアプリケーション終了 ②再起動後 以下のようなコードでNCMBUserクラスをコンストラクト if (NCMBUser.CurrentUser == null) { _user = new NCMBUser(); _user.ACL = acl; } else { _user = NCMBUser.CurrentUser; _user.ACL = acl; } ③その際に以下のエラーが発生します NCMBException: The requested operation caused a stack overflow. NCMB.NCMBObject._getFromDisk (System.String fileName) (at Assets/NCMB/Script/NCMBObject.cs:1369) NCMB.NCMBUser.get_CurrentUser () (at Assets/NCMB/Script/NCMBUser.cs:122) UserAuth.Init () (at Assets/Scripts/NCMB/UserAuth.cs:61) StartManager.Awake () (at Assets/Scripts/Title/StartManager.cs:61)

④対象のファイルは以下になります {"acl":{"*":{"read":true,"write":true}},"authData":{"anonymous":{"id":"996d17f1-3085-4880-ad06-237695f21666"}},"sessionToken":"BD1su2RLrWOIRiof2b39zrjon","userName":"U8sauoTlZE","createDate":"2023-01-22T23:41:47.382Z","updateDate":"2023-01-22T23:41:47.382Z","objectId":"bkfESZpwP6sLwdP7","className":"user"}

解決策のご教授をお願い致します。

akiaki2020 commented 1 year ago

追記 デバック時のStackTraceは以下になります at NCMB.NCMBObject.CreateWithoutData (System.String className, System.String objectId) [0x00040] in C:\Users\roket\OneDrive\ドキュメント\cky-board-game\Assets\NCMB\Script\NCMBObject.cs:1163 at NCMB.NCMBObject._getFromDisk (System.String fileName) [0x00042] in C:\Users\roket\OneDrive\ドキュメント\cky-board-game\Assets\NCMB\Script\NCMBObject.cs:1364

akiaki2020 commented 1 year ago

上記の件ですが解決いたしました。

if (NCMBUser.CurrentUser == null) 上記コードを実行する前に

下記のようなコードで。 NCMBACLのオブジェクトを生成したのが原因でした。 ////NCMBACLオブジェクトを作成 NCMBACL acl = new NCMBACL(); NCMBACL.SetDefaultACL(acl, true); //読み込み権限を全開放 acl.PublicReadAccess = true; //書き込み権限を全開放 acl.PublicWriteAccess = true;