Open neervanbiqs opened 1 year ago
Does it happen only with one activity in particular?
Can you share a reproducible example?
curl http://localhost:9987/v2/uiDevice/dumpWindowHierarchy?format=xml --> 1-4 sec delay (especially on first command)
It greatly depends on the complexity of the Activity and how long it takes UiAutomator to reconstruct the hierarchy.
I've run this python example what would be easier to time
#! /usr/bin/env python3
import time
from com.dtmilano.android.viewclient import ViewClient
device, serialno = ViewClient.connectToDeviceOrExit()
helper = ViewClient(device, serialno, useuiautomatorhelper=True).uiAutomatorHelper
t = [time.time()]
pkg = 'com.google.android.calculator'
act = 'com.android.calculator2.Calculator'
device.forceStop(pkg)
helper.target_context.start_activity(pkg, act)
# helper.target_context.start_activity('com.android.chrome',
# 'com.google.android.apps.chrome.Main',
# uri='https://google.com')
helper.ui_device.wait_for_window_update()
t.append(time.time())
for n in range(4):
helper.ui_device.dump_window_hierarchy()
t.append(time.time())
device.forceStop(pkg)
and I got
0.175s
0.537s
0.050s
0.061s
with Calculator but
0.197s
1.628s
2.474s
0.159s
with Chrome.
I found that the window has the inlined image banner that is sometimes drawn. When it is not drawn, the dump is very fast and vice versa
I would be helpful if you can replace pkg
, act
and uri
in the previous script, run it and provide the timing output.
1.485s 3.645s 1.253s 2.794s
PS After inetnt was launched the apk first shows the launched activity and after that (in about 1-3 secs) it also draw the inlined banner. While this banner is not drawed the delay is persist. After the banner was drawn dump executed immediatly
When I try start an activity of some app and immediately curl dumpWindowHierarchy the command is executed for about three seconds (intent started in about one second). All other cases with dump executed very fast. Why?