From d2550d75178d228135ca2c453fbaf6f75c288061 Mon Sep 17 00:00:00 2001 From: Norne Date: Fri, 30 Dec 2022 20:28:32 +0300 Subject: [PATCH] Better documentation --- CHANGELOG.md | 4 ++ Documentation~/com.norne.anrwatchdog.md | 69 +++++++++++++++++++++++-- package.json | 2 +- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dd007e..1d1fe30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.0.1 + +- Better documentation + ## v1.0.0 - The first version of the package diff --git a/Documentation~/com.norne.anrwatchdog.md b/Documentation~/com.norne.anrwatchdog.md index 2dc8703..0c6eba9 100644 --- a/Documentation~/com.norne.anrwatchdog.md +++ b/Documentation~/com.norne.anrwatchdog.md @@ -1,9 +1,65 @@ # ANR Watchdog -## Watchdog +## Overview -This package will allow you to reduce the number of ANRs of your application. -This is achieved by using a watchdog timer which will restart the application in case something goes wrong. +This package will allow you to reduce the number of ANRs of your application. This is achieved by using a watchdog timer +which will restart the application in case something goes wrong. + +## Installation instructions + +[Official Package Manager installation instructions](https://docs.unity3d.com/Manual/upm-ui-install.html) + +## Workflows + +After adding the package to your project you are ready to go! + +### Timeout Configuration + +You can change the timeout after which your app will restart. The ANR detection timeout in Android is 10 seconds. +Therefore, I recommend keeping it below this value. The default value is 9 seconds. + +Example: + +```csharp +using Norne; +using UnityEngine; + +public class ChangeTimeout: MonoBehaviour +{ + private void Start() + { + // Set timeout to 8 seconds + Watchdog.Timeout = 8f; + } +} +``` + +### Analytics + +Using this package prevents ANR data from being automatically sent to Google Play. If you are interested in this data +you can still receive it and send it to any analytics service. + +Example code: + +```csharp +using Norne; +using UnityEngine; + +public class SendStacktrace: MonoBehaviour +{ + private void Start() + { + // Check if we got an ANR the last time we ran the application + if (Watchdog.TryGetStacktrace(out var stacktrace)) + { + // If we did, send it to our analytics service + Analytics.Send("ANR", stacktrace); + } + } +} +``` + +## Reference ### Watchdog.Timeout @@ -56,4 +112,9 @@ public class SendStacktrace: MonoBehaviour } } } -``` \ No newline at end of file +``` + +## Samples + +- **Watchdog Sample** - + Contains a sample that shows how the app reacts to ANRs and how to change the timeout diff --git a/package.json b/package.json index 51b1d1a..e2daa10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.norne.anrwatchdog", - "version": "1.0.0", + "version": "1.0.1", "description": "This package will allow you to reduce the number of ANRs of your application. This is achieved by using a watchdog timer which will restart the application in case something goes wrong.", "displayName": "ANR Watchdog", "unity": "2018.4",