Repository navigation
fix(android): bound helper output and handle clipped text #5245
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
Changes from all commits
24ca465
5b36515
cd5ec29
54b6189
3070f6f
2e43d99
6bc4fcf
f3bacc0
a378cf3
f8a7d17
5ec69ce
accbe07
d26a187
5f1b9df
a950ea5
4bd3b1a
b791ee2
60e55bd
503229c
fdf0502
d8efb52
59a1e54
530e259
34cfb92
d9323ac
7e9c0c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,10 +62,13 @@ | |
| ? null | ||
| : stats.activeWindowMetadata.withIndex(windowCount); | ||
| if (root != null | ||
| && AccessibilityTreeXml.remainingDocumentChars(xml) | ||
| > AccessibilityTreeXml.NODE_SUFFIX_RESERVE_CHARS | ||
| && AccessibilityCaptureStabilizer.canAppendActiveWindowFallback( | ||
| windowCount, fallbackMetadata != null)) { | ||
| AccessibilityTreeXml.appendNode( | ||
| xml, root, windowCount, 0, maxDepth, maxNodes, stats, fallbackMetadata); | ||
| xml, root, windowCount, 0, maxDepth, maxNodes, stats, fallbackMetadata, | ||
| xml.length() + AccessibilityTreeXml.remainingDocumentChars(xml)); | ||
| windowCount += 1; | ||
| stats.activeWindowRootMissing = false; | ||
| } | ||
|
|
@@ -190,11 +193,13 @@ | |
| return 0; | ||
| } | ||
| int windowCount = 0; | ||
| for (int index = 0; index < windows.size(); index += 1) { | ||
| if (stats.nodeCount >= maxNodes) { | ||
| if (stats.nodeCount >= maxNodes | ||
| || AccessibilityTreeXml.remainingDocumentChars(xml) | ||
| <= AccessibilityTreeXml.NODE_SUFFIX_RESERVE_CHARS) { | ||
| stats.truncated = true; | ||
| break; | ||
| } | ||
|
Check warning on line 202 in android/snapshot-helper/src/main/java/com/callstack/agentdevice/snapshothelper/AccessibilityTreeCapture.java
|
||
|
Comment on lines
196
to
202
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🆕 🟡 Minor · Character-budget break in the window loop skips windows without marking their roots missing When the XML character budget is consumed by an earlier window (e.g. IME), Detailspersona: Useful? Reply Reply |
||
| AccessibilityWindowInfo window = windows.get(index); | ||
| AccessibilityNodeInfo root = null; | ||
| boolean activeWindow = isActiveWindow(window); | ||
|
|
@@ -222,7 +227,8 @@ | |
| maxDepth, | ||
| maxNodes, | ||
| windowStats, | ||
| windowMetadata); | ||
| windowMetadata, | ||
| AccessibilityTreeXml.remainingDocumentChars(xml)); | ||
| xml.append(windowXml); | ||
|
Check warning on line 232 in android/snapshot-helper/src/main/java/com/callstack/agentdevice/snapshothelper/AccessibilityTreeCapture.java
|
||
| stats.copyFrom(windowStats); | ||
| windowCount += 1; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🆕 🟡 Minor · Window loop's <= reserve check lets one more window cross the 8 MiB document cap
A capture whose document ends with
remainingDocumentChars(xml) == NODE_SUFFIX_RESERVE_CHARS + 1(≈540,704 chars) passes the loop's<=guard, so the window lands pastMAX_XML_CHARSat ~8 MiB + 540K chars.appendNode's guard is>=but the window path checksxml.length() + reserve >= maxXmlCharsinside a fresh builder starting at 0, so it double-counts the reserve.Suggested change
Raised as major, posted as minor: no verification confirmed it.
Details
persona:
senior-developerUseful? Reply
@apex-sentinel-staging like, or@apex-sentinel-staging dislike <why>if it is not.Reply
@apex-sentinel-staging note ...to add context, or@apex-sentinel-staging pivot ...if it is wrong — I will re-check the cited code.