Commit b3b2719
perf(flutter): Move Android JNI work to core worker to avoid work on main isolate (#3713)
* perf(flutter): Optimize Android scope sync
Send large Android scope payloads as JSON bytes instead of recursively
constructing Java maps and lists through JNI. This keeps nested user data
structured while reducing per-entry JNI object churn.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* docs(flutter): Document JNI payload guidance
Clarify that large or arbitrary Dart collection payloads should cross
JNI as JSON bytes, while primitives and small controlled payloads can use
direct conversion.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* style(flutter): Wrap JNI JSON reader helper
Keep the Android JSON reader helper within ktlint formatting limits after
adding the scope sync byte-array bridge.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* style(flutter): Apply ktlint when-branch formatting
Wrap all native JSON conversion when branches consistently so ktlint accepts
the multiline Kotlin helper added for Android scope sync.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* ref(flutter): Reuse native data normalizer
Use the existing native boundary normalizer before encoding Android scope
payloads as JSON bytes instead of maintaining a second normalization helper.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(flutter): Preserve nulls in Android JSON bridge
Keep null values when converting JSON object and array payloads on Android
so the bridge remains lossless before native model deserialization.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* perf(flutter): Reuse Android JSON deserializers
Cache JSON deserializers for scope sync payloads and replace the broad
Any extension with a private helper function for Kotlin JSON conversion.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* ref(flutter): Use SDK JSON object reader
Use the Java SDK JSON reader for context payload parsing instead of a
custom recursive org.json conversion helper.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* docs(flutter): Clarify JSON reader parsing
Document that the Android JSON reader accepts root-level primitives
so future changes do not replace it with object-only parsing.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(flutter): Wrap Android primitive contexts
Route Android context values through sentry-java's typed overloads so
primitive Dart context values are serialized as valid context objects.
Regenerate JNI bindings after removing the unused object overload entrypoint.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(flutter): Release Android JNI refs
Release replay callback JNI handles after processing replay privacy
options, and avoid creating duplicate JNI strings when loading debug
images. This reduces leaked global refs in Android replay and debug image
paths.
Fixes #3696
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* test(flutter): Expect wrapped Android contexts
Update the native context sync test to match the Android bridge's
valid serialized shape for primitive context values.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(flutter): Release replay JNI refs safely
Use a single arena for replay callback JNI temporaries and avoid
releasing map keys before removing privacy options from the payload.
Refs #3696
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* ref(flutter): Move Android JNI work to core worker
Route Android native scope and context work through the core worker so
JNI calls can run off the main isolate when the worker is available.
Keep current-isolate fallbacks for calls made before startup.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(flutter): Harden Android core worker
Handle worker request failures without crashing callers and normalize
payloads before sending them across isolates. Track JNI strings as they
are allocated so partial failures still release native refs.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(flutter): Await Android scope worker sync
Return worker request futures for Android scope updates so awaited scope
observer calls complete after native scope synchronization finishes.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(flutter): Serialize Android scope updates
Route paired Android scope mutations through the same worker queue so
call order is preserved across breadcrumb and context updates. Handle
worker startup failures without delaying native SDK initialization.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(flutter): Skip Android worker reads after close
Return null for Android core worker read paths after shutdown so closed
workers do not fall back to JNI work on the main isolate.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* style(flutter): Format Android core worker
Apply formatting to the Android core worker and clarify that its
internal queue preserves JNI request order.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* ref(flutter): Expand Android worker update helpers
Use explicit worker request helpers for each Android scope mutation so
request construction and error logging stay local to each operation.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* ref(flutter): Reuse Android scope normalizer
Route Android core worker scope payloads through the shared normalizer
to avoid broadening behavior in this refactor.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* ref(flutter): Use normalize for worker payloads
Align Android worker scope payload normalization with the shared helper
without changing the surrounding worker request flow.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent e8f0fc4 commit b3b2719
8 files changed
Lines changed: 1296 additions & 441 deletions
Lines changed: 737 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 0 additions & 120 deletions
This file was deleted.
Lines changed: 17 additions & 129 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | | - | |
35 | | - | |
| 34 | + | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 65 | + | |
| 66 | + | |
119 | 67 | | |
120 | 68 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 69 | + | |
153 | 70 | | |
154 | 71 | | |
155 | 72 | | |
| |||
198 | 115 | | |
199 | 116 | | |
200 | 117 | | |
201 | | - | |
| 118 | + | |
202 | 119 | | |
203 | 120 | | |
204 | 121 | | |
205 | 122 | | |
206 | 123 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
| 124 | + | |
| 125 | + | |
215 | 126 | | |
216 | 127 | | |
217 | | - | |
218 | | - | |
219 | | - | |
| 128 | + | |
220 | 129 | | |
221 | 130 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 131 | + | |
232 | 132 | | |
233 | 133 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
| 134 | + | |
| 135 | + | |
242 | 136 | | |
243 | 137 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
| 138 | + | |
251 | 139 | | |
252 | 140 | | |
253 | 141 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
0 commit comments