sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

Offload NDK Scope sync to background thread

Open markushi opened this issue 2 years ago • 4 comments

Problem Statement

As of now any context data (user, breadcrumb, tags, ...) is synced to sentry-native on the calling thread. The calling thread might be the main thread, which is not optimal.

Solution Brainstorm

We should offload the scope sync to a background thread, ensuring we're not spending too much time on the main thread.

markushi avatar Nov 10 '23 07:11 markushi

Let's be aware if the sync happens on a background thread, the data won't be available immediately on the NDK side. E.g. when next line in code performs JNI call.

markushi avatar Nov 29 '23 15:11 markushi

Let's talk about this in the next sentry-native sync.

markushi avatar Nov 29 '23 15:11 markushi

Let's check the top-level attributes in the data bag: If it's only primitives sync the breadcrumbs directly, otherwise offload to a background thread.

markushi avatar Dec 13 '23 15:12 markushi

Let's also profile/compare the timings of syncing this with only primitives. If it's quick enough we could still do that on the main thread, otherwise offload to a bg thread

romtsn avatar Jun 05 '24 13:06 romtsn