Repository navigation
Serve secure rectangles from the versioned pull buffer - #20
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Deep code review (PR #20, 30caf3d)
This correctly closes the leftover from #8: 7.x video redaction polls the wrapper pull path, and UnityWrapper.getSecureRectangles previously always returned [1, 0]. Imperative Add/Remove/RemoveAll now own per-LTRB manual: registry entries, snapshot with convert-then-outward-round, and push-on-write into the native cache.
I did not review the diff in isolation. Checked the public facade, SecureRectRegistry / SecureRectManualOwners, Android/iOS bridges, Java/ObjC wrapper caches, the deleted BugseeWrapperProxy, sample callers, and the actual native contracts:
- Android 7.3.0 AAR:
BugseeWrapper.getSecureRectangles(int)packed[version, count, l,t,r,b,…];BugseeSecureViewsManagerclamps count, treats version0as unknown, and oncount <= 0clears wrapper rects and resets last-version to0(so Stop/Launch still reapplies a cached non-zero version). - Android public
Bugsee.addSecureRectanglealso hardcodes display 0 — same asDefaultSecureRectDisplayId. - iOS 7.0.0-beta5
BGSContracts.h:secureRectanglesForDisplay:is the same layout in little-endianint32_t; coordinates are points, origin top-left, exclusiver/b, outward round; iOS only polls display 0; stale version + changed rects is a documented privacy defect —Snapshotonly skips the bump when the converted ints are equal.
No P0–P3 issues that I can back with a concrete failure scenario.
Checks that did not become findings
- JNI
CallStatic("setSecureBuffer", display, packed): mixedint+int[]binds toparams object[], so theint[]is not expanded into(I)(I)(I)…(that pitfall isCallStatic(name, packed)alone). - iOS P/Invoke passes explicit
packed.Length; native copiespackedLength * sizeof(int32_t)undergLockand returns an immutable snapshot on pull (matches the SDK “engine thread must not mutate a liveNSMutableData” rule). - Last-remove publishes a version > last non-empty and ≠ 1, so native does not treat it as the initial empty
[1, 0]. RemoveAllonly strips themanual:prefix, so a future HUD owner survives; that matches native (wrapper pull is merged with, not replaced by,addSecureRectangle).
Could not run dotnet test here (SDK not installed). Source tests lock the wiring; they do not execute JNI/PInvoke.
1. Overall risk: Low
2. Merge recommendation: Approve
3. Most important issues to fix
None required for merge.
Residual (not blocking): wrapper-policy tests are source greps; Tests~/Android still only checks that getSecureRectangles exists in the class pool, and iOS BridgeTests.mm never round-trips _bugsee_set_secure_buffer / secureRectanglesForDisplay:. A same-package Java test (setSecureBuffer → new UnityWrapper().getSecureRectangles) would catch a clone/cache miss without Unity.
4. Positive observations
- This is the right 7.x path: stop calling public
addSecureRectangle/addSecureRectangle:and serve the versioned pull buffer, including deleting the deadBugseeWrapperProxy(never registered after #9). - Scale split is correct against the SDK header (Android pixels / scale 1, iOS
UIScreen.scalepoints) and matchesSecureRectRegistry’s existing outward-round tests. - Android clones on both put and get; iOS copies into
NSData. ProGuard keep forsetSecureBuffermatches the existing JNI keep list (channelLog,refineContext).
Sent by Cursor Automation: Bugsee code review


Summary
SecureRectRegistrywith per-rect manual owner ids and push-on-write to native pull buffers.UnityWrapper.setSecureBufferand iOS_bugsee_set_secure_bufferstore the last packed mask; wrapper pull returns that buffer (or[1, 0]before any push).addSecureRectanglebridge paths and the unusedBugseeWrapperProxy.Test plan
DOTNET_ROLL_FORWARD=LatestMajor dotnet test Tests~/WrapperPolicy/Bugsee.WrapperPolicy.Tests.csproj --filter "SecureRect"(15 passed locally)Bugsee.WrapperPolicy.Testssuite (151 passed locally)Made with Cursor