[x] Singleton GameObject created at startup (SentryUnityOptions) to cache stuff on UI thread (revert from deferred execution)
[x] Cache aggressively all values that profiler shows (any timestamps visible in dotTrace)
// Not cached and must be called from UI thread, won't be shown if `SentrySdk.CaptureEvent` called on non-UI thread
SystemInfo.batteryStatus
SystemInfo.batteryLevel
Input.deviceOrientation
// Cached, isn't shown in dotTrace, must be called from UI thread
SystemInfo.processorCount
SystemInfo.processorType
SystemInfo.supportsVibration
// etc
// Cached, shown in dotTrace, must be called from UI thread
new Lazy(() => SystemInfo.deviceUniqueIdentifier)
new Lazy(() => SystemInfo.deviceModel)
new Lazy(() => SystemInfo.graphicsDeviceVendorID.ToString())
// etc
- [x] `Task.Run(() => SentrySdk.CaptureEvent(sentryEvent));` must not fail and send the event
- [x] If `SentrySdk.CaptureEvent` is called from non-UI thread, make sure the event processing won't fail (because of calling Unity APIs from non-UI thread). But if `SentrySdk.CaptureEvent` is called in UI thread and then non-UI thread (`Task.Run`), populate the data from cached value
```csharp
// In order to have `SystemInfo.deviceType` set in `SentryEvent.Device.DeviceType`, we must call it from UI thread.
// first call, non-UI thread, `SentryEvent.Device.DeviceType` is `null`
Task.Run(() => SentrySdk.CaptureEvent(sentryEvent));
// second call, UI thread, `SentryEvent.Device.DeviceType` is NOT `null` and equals to 'Desktop'
SentrySdk.CaptureEvent(sentryEvent);
// third call, non-UI thread, `SentryEvent.Device.DeviceType` is NOT `null` and equals to 'Desktop'
Task.Run(() => SentrySdk.CaptureEvent(sentryEvent));
GameObject
created at startup (SentryUnityOptions
) to cache stuff on UI thread (revert from deferred execution)// Cached, isn't shown in dotTrace, must be called from UI thread SystemInfo.processorCount SystemInfo.processorType SystemInfo.supportsVibration // etc
// Cached, shown in dotTrace, must be called from UI thread new Lazy(() => SystemInfo.deviceUniqueIdentifier) new Lazy(() => SystemInfo.deviceModel) new Lazy(() => SystemInfo.graphicsDeviceVendorID.ToString()) // etc