Skip to content

[Android] snapshot returns 1 node on Telegram while stock uiautomator dump sees the full tree (descent stops at depth 4) #1733

Description

@TheVilfer

Summary

On Telegram for Android (stock APK from telegram.org), agent-device snapshot returns a single node and the "sparse accessibility snapshot" hint, on every screen I could reach. Plain adb shell uiautomator dump captures the full view tree on the exact same screen, including TextViews with their texts and EditTexts — so the hierarchy is there and is reachable through UiAutomation; the snapshot helper just stops descending.

snapshot --raw shows the Telegram window is found, but the walk ends at a full-screen android.view.View at depth 4 with no children, while com.android.systemui in the same capture is walked down to depth 11.

This looks related to #850 (Fabric: only system window returned), but the app here is not React Native — it is Telegram's own native custom-view UI.

Environment

  • agent-device: 0.20.7
  • Host: macOS 26.5.2, Apple M4 Pro, Node v24.18.0
  • adb: 1.0.41 (platform-tools 37.0.1), emulator 37.1.11
  • Device: AVD pixel_7, system-images;android-35;google_apis;arm64-v8a, SDK 35, abi arm64-v8a, headless (-no-window), 6 GB RAM
  • App: Telegram org.telegram.messenger.web, versionName 12.9.2, versionCode 69919, targetSdk 35 (universal APK from https://telegram.org/dl/android/apk)

Repro

adb install -r telegram.apk
agent-device open org.telegram.messenger.web --platform android --device <avd> --foreground

Actual — agent-device

$ agent-device snapshot -i --platform android --device agentfarm-a35
Page: org.telegram.messenger.web
App: org.telegram.messenger.web
Snapshot: 1 nodes
Hint: sparse accessibility snapshot returned 1 node; snapshot state is invalid or unavailable for this screen.

snapshot --raw — all six Telegram nodes, descent stops at depth 4:

{"index":27,"type":"android.widget.FrameLayout","bundleId":"org.telegram.messenger.web","rect":{"x":0,"y":0,"width":1080,"height":2400},"depth":0,"ref":"e28"}
{"index":28,"type":"android.widget.FrameLayout","bundleId":"org.telegram.messenger.web","depth":1,"parentIndex":27,"ref":"e29"}
{"index":29,"type":"android.widget.LinearLayout","bundleId":"org.telegram.messenger.web","depth":1,"parentIndex":27,"ref":"e30"}
{"index":30,"type":"android.widget.FrameLayout","identifier":"android:id/content","bundleId":"org.telegram.messenger.web","depth":2,"parentIndex":29,"ref":"e31"}
{"index":31,"type":"android.widget.FrameLayout","bundleId":"org.telegram.messenger.web","depth":3,"parentIndex":30,"ref":"e32"}
{"index":32,"type":"android.view.View","bundleId":"org.telegram.messenger.web","rect":{"x":0,"y":0,"width":1080,"height":2400},"hittable":true,"depth":4,"parentIndex":31,"ref":"e33"}

Expected — stock UiAutomator on the same screen

$ pkill -f agent-device            # see "Diagnostic trap" below
$ adb shell uiautomator dump /sdcard/tg.xml
$ adb shell cat /sdcard/tg.xml
... class="android.widget.ScrollView"
... class="android.widget.TextView" text="Telegram"
... class="android.widget.TextView" text="The world's fastest messaging app.&#10;It is free and secure."
... class="android.widget.TextView" text="Start Messaging"

On the phone-number screen further in, the same dump additionally shows android.widget.EditText nodes and the "Your phone number" / "Please confirm your country code…" texts. uiautomator dump --compressed returns an equally rich tree, so this is not an important-for-accessibility filtering effect.

Ruled out

  • Not app-wide / not the backend in general — stock Settings (com.android.settings) returns 13 interactive / 28 nodes, and third-party sideloaded F-Droid (org.fdroid.fdroid) returns 14 / 18 on the same AVD in the same session. Telegram is the outlier.
  • Not memory — reproduced with 2 GB and 6 GB AVD RAM; MemAvailable ~4.3 GB at capture time.
  • Not the renderer — reproduced with both -gpu swiftshader_indirect and -gpu host.
  • Not the persistent helper sessionAGENT_DEVICE_ANDROID_SNAPSHOT_HELPER_SESSION=0 with a fresh daemon gives the identical 1-node result.
  • Not a settle/timing race — repeated snapshots after several seconds, and after press … --settle, are identical.
  • Not compressed-hierarchy filtering — both uiautomator dump and uiautomator dump --compressed return the full tree.
  • Not window scoping--raw proves the Telegram window is captured; only the descent is truncated.

Diagnostic trap worth documenting

While a agent-device daemon is alive, adb shell uiautomator dump fails with rc=137 / Killed, and logcat shows:

E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: java.lang.IllegalStateException: UiAutomationService android.accessibilityservice.IAccessibilityServiceClient$Stub$Proxy@… already registered!
	at android.app.UiAutomationConnection.registerUiTestAutomationServiceLocked(UiAutomationConnection.java:651)
	at com.android.commands.uiautomator.DumpCommand.run(DumpCommand.java:78)

Anyone cross-checking a sparse snapshot against stock UiAutomator must pkill -f agent-device first, otherwise the control experiment silently fails and looks like a device/app problem. This tripped me up for several iterations and may be worth a line in help debugging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions