Skip to content

Commit 5137bbe

Browse files
authored
Merge pull request #453 from microsoft/fix/unhandled-crashes-fix
IOS new thread exception crash report fix
2 parents 19f4172 + b85821d commit 5137bbe

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

Assets/AppCenter/Plugins/AppCenterSDK/Crashes/Shared/Crashes.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,15 @@ public static void OnHandleUnresolvedException(object sender, UnhandledException
7878
if (exception != null)
7979
{
8080
Debug.Log("Unhandled exception: " + exception.ToString());
81+
#if UNITY_IOS && !UNITY_EDITOR
82+
TrackErrorWithAttachments(exception);
83+
#else
8184
lock (_unhandledExceptions)
8285
{
8386
_unhandledExceptions.Enqueue(exception);
8487
}
8588
UnityCoroutineHelper.StartCoroutine(SendUnhandledExceptionReports);
89+
#endif
8690
}
8791
}
8892
#endif
@@ -326,18 +330,25 @@ private static IEnumerator SendUnhandledExceptionReports()
326330
}
327331
if (exception != null)
328332
{
329-
var exceptionWrapper = CreateWrapperException(exception);
330-
var errorId = CrashesInternal.TrackException(exceptionWrapper.GetRawObject(), null, null);
331-
if (_enableErrorAttachmentsCallbacks)
332-
{
333-
SendErrorAttachments(errorId);
334-
}
333+
TrackErrorWithAttachments(exception);
335334
}
336335
yield return null; // report remaining exceptions on next frames
337336
}
338337
}
339338
#endif
340339

340+
private static void TrackErrorWithAttachments(Exception exception)
341+
{
342+
var exceptionWrapper = CreateWrapperException(exception);
343+
var errorId = CrashesInternal.TrackException(exceptionWrapper.GetRawObject(), null, null);
344+
345+
// If the main thread is not crashed, attachments should be sent.
346+
if (_enableErrorAttachmentsCallbacks)
347+
{
348+
SendErrorAttachments(errorId);
349+
}
350+
}
351+
341352
private static WrapperException CreateWrapperException(Exception exception)
342353
{
343354
var exceptionWrapper = new WrapperException();

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# App Center SDK for Unity Change Log
22

3+
## Release 3.2.1 (in development)
4+
5+
### App Center
6+
7+
#### iOS
8+
9+
* **[Fix]** Fix reporting crashes caused by a thread exception.
10+
311
## Release 3.2.0
412

513
### App Center

0 commit comments

Comments
 (0)