Skip to content

Cache, background threads and data for UnityEventProcessor #267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks done
semuserable opened this issue Jul 23, 2021 · 1 comment
Closed
5 tasks done

Cache, background threads and data for UnityEventProcessor #267

semuserable opened this issue Jul 23, 2021 · 1 comment
Assignees
Labels
Feature New feature or request

Comments

@semuserable
Copy link
Contributor

semuserable commented Jul 23, 2021

  • Singleton GameObject created at startup (SentryUnityOptions) to cache stuff on UI thread (revert from deferred execution)
  • 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
  • Task.Run(() => SentrySdk.CaptureEvent(sentryEvent)); must not fail and send the event
  • 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
// 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));
  • Tests
@semuserable semuserable self-assigned this Jul 23, 2021
@semuserable semuserable added the Feature New feature or request label Jul 23, 2021
@semuserable
Copy link
Contributor Author

semuserable commented Jul 29, 2021

closed by #268

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant