facebook twitter hatena line email

Unity/sentry/BREAKPOINT対応

提供: 初心者エンジニアの簡易メモ
2023年10月13日 (金) 13:52時点におけるAdmin (トーク | 投稿記録)による版 (ページの作成:「==BREAKPOINT対応== iOSのビルド設定のOtherSettingsのOptimizationのScriptCallOptimizationを、 "Slow and Safe"から"Fast but no Exceptions"にして、Exceptio...」)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

BREAKPOINT対応

iOSのビルド設定のOtherSettingsのOptimizationのScriptCallOptimizationを、 "Slow and Safe"から"Fast but no Exceptions"にして、Exceptionをtry-catchなしで実行すると、EXC_BREAKPOINTで、クラッシュして、アプリが落ちる

Unity/負荷軽減/モバイル [ショートカット]

try-catchなしで、Exceptionを投げる例

public class ExceptionScene : MonoBehaviour
{
    [SerializeField] Button button1;
    void Start()
    {
        button1.onClick.AddListener(() =>
        {
            Exec();
        });
    }
    void Exec()
    {
        throw new Exception("例外エラーNormal");
    }
}

以下、”Fast but no Exceptions"の設定で、Exceptionしてクラッシュした時のEXC_BREAKPOINT

extern "C" void CrashedCheckBelowForHintsWhy()
{
#if ENABLE_IOS_CRASH_REPORTING || ENABLE_CUSTOM_CRASH_REPORTER
    // Make app crash hard here
    __builtin_trap(); # ←ここで、"Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1093ee874)"エラーが起こった

    // Just in case above doesn't work
    abort();
#endif
}

sentryのログ調査

"Slow and Safe"のときのthrow new Exception()実行時は、以下がsentryログに上がる

System.Exception 
ExceptionScene in Exec
例外エラーNormal

"Fast but no Exceptions"のときのthrow new Exception()実行時は、アプリが落ちるが、以下がsentryログに上がる

EXC_BREAKPOINT 
InitCrashHandling
000000000000000000000000000>:0  > Exception > text.Exec () [0x00000] in <00000000000000000000000000000000>:0  > 例外エラーNormal