Repository navigation
Feat: Add iOS helpers that put secure rectangles in screen points for SDK 7 - #1
Draft
dsheikherev wants to merge 1 commit into
Draft
dsheikherev wants to merge 1 commit into
dsheikherev wants to merge 1 commit into
Conversation
… SDK 7
The 7.x iOS SDK records every window of the app at its place on the
screen, and it pulls a wrapper's secure rectangles through
-[BGSBugseeWrapper secureRectanglesForDisplay:] as
[version, count, left, top, right, bottom, ...] in screen points
(BGSContracts.h). The Dart side (lib/src/ui.dart) sends five ints per
secure widget, [id, x, y, width, height], measured from the Flutter
view's origin in points (the device pixel ratio is forced to 1 on iOS);
the 6.x SDK reads that payload with a 20-byte stride. With SDK 7, a
Flutter view that does not start at the screen's origin would be recorded
in the clear: an iPad window in Stage Manager or Split View, or the
iPhone Duo with two windows side by side.
- BGSFlutterSecureRectanglesBuffer takes the Dart payload as it is,
moves every rectangle by the view's origin on the screen, rounds the
edges outward, and packs the result for the contract. The version is
always 0, so the SDK compares the rectangles itself: the result also
changes when only the window moves, and Dart publishes nothing then.
A malformed input (no data with a non-zero count) returns nil, which
the caller must not hand to the SDK, as nil clears the rectangles.
- BGSFlutterViewOriginOnScreen returns where the Flutter view starts in
the frame the SDK records. It uses the SDK's own conversion: through
the screen's fixed space, or the window's frame origin on Mac Catalyst,
for iOS apps on a Mac and for a window on no screen.
Nothing calls these helpers yet: the plugin still uses the 6.x API
(setInternalSecureRectangles:). When the plugin moves to SDK 7, call them
from the wrapper's secureRectanglesForDisplay:. The React Native wrapper
uses the same conversion (bugsee-react-native#30).
Checked:
- Compiles without warnings for an iOS 11 simulator and device, an
iOS 15 device and Mac Catalyst.
- 13 buffer checks pass, including a payload built the way ui.dart builds
it (two obscured text fields) and the iPad case: {60, 260} in a window
at {359, 64} becomes {419, 324}.
- The view origin is correct in portrait and landscape on an iPhone 17
Pro simulator (one full-screen scene; the offset-window branch is the
SDK's formula, not exercised here).
- An adversarial review found that an earlier draft read four ints in
physical pixels; it would have redacted nothing.
The plugin has no iOS test target, so these checks ran outside the repo.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The 7.x iOS SDK records every window of the app at its place on the screen (bugsee/bugsee-cocoa#170). Since bugsee/bugsee-cocoa#186 it keeps doing that while secure rectangles are registered. It pulls a wrapper's secure rectangles through
-[BGSBugseeWrapper secureRectanglesForDisplay:]and expects[version, count, left, top, right, bottom, ...]as packedint32, in screen points (BGSContracts.h).The Dart side (
lib/src/ui.dart,_addElementBounds) sends five ints per secure widget:[id, x, y, width, height]. They are measured from the Flutter view's origin, in points; on iOS the device pixel ratio is forced to 1. The 6.x SDK reads that payload through+[Bugsee setInternalSecureRectangles:]with a 20-byte stride. That method does not exist in 7.x.If the plugin forwarded the values unchanged to 7.x, a Flutter view that does not start at the screen's origin would be recorded in the clear, with the black off to the side of it. That happens to an iPad window in Stage Manager or Split View, and to the iPhone Duo with two windows side by side.
What
New files only, in
ios/bugsee_flutter/Sources/bugsee_flutter/. They are private headers (not ininclude/) under both CocoaPods and SPM.BGSFlutterSecureRectanglesBuffer(elements, intCount, origin)takes the Dart payload as it is.0(BGSSecureRectanglesVersionUnknown), so the SDK compares the rectangles itself. The result also changes when only the window moves, for example in a Stage Manager drag, and Dart publishes nothing then. A version derived from Dart's publishes would go stale, which the contract calls a privacy defect.nil. The caller must not hand that to the SDK, becausenilclears the rectangles.BGSFlutterViewOriginOnScreen(view, &origin)returns where the Flutter view starts in the frame the SDK records. It uses the SDK's own conversion (+[BGSTrackerApplication screenRectForRect:inView:]): through the screen's fixed space. On Mac Catalyst, for iOS apps on a Mac and for a window on no screen, it falls back to the window's frame origin.When the plugin moves to 7.x, call both from the wrapper's
secureRectanglesForDisplay:, on the main thread. The React Native wrapper uses the same conversion (bugsee/bugsee-react-native#30).Checks
The plugin has no iOS test target and Flutter was not installed on the machine, so the checks ran outside the repo.
-Wall -Wextra -Werrorand the availability warnings for an iOS 11 simulator and device, an iOS 15 device, and Mac Catalyst.ui.dartbuilds it (two obscured text fields) lands on the fields, both with the view at the screen origin and with the view at{359, 64};{60, 260}in a window at{359, 64}becomes{419, 324};nilcase, and immutability of the result.An adversarial review caught that an earlier version read four ints in physical pixels. Fed the real payload, it would have redacted nothing.
Known gap, for the move to 7.x
Dart rounds
x, y, width, heightto whole points withround(), so an edge can sit up to half a point inside the widget. Rounding outward on the Dart side (floor the left and top, ceil the right and bottom) would close that.Base
The base is
releasebecause this branch starts at 9.0.5. Againstmain(9.0.2) the PR would also carry the 9.0.3–9.0.5 bump commits. Retarget as needed.🤖 Generated with Claude Code