Skip to content
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

Big delay #17

Open
neervanbiqs opened this issue Oct 24, 2022 · 6 comments
Open

Big delay #17

neervanbiqs opened this issue Oct 24, 2022 · 6 comments

Comments

@neervanbiqs
Copy link

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?

@dtmilano
Copy link
Owner

Does it happen only with one activity in particular?

Can you share a reproducible example?

@neervanbiqs
Copy link
Author

neervanbiqs commented Oct 24, 2022

curl http://localhost:9987/v2/uiDevice/dumpWindowHierarchy?format=xml --> 1-4 sec delay (especially on first command)

@dtmilano
Copy link
Owner

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.

@neervanbiqs
Copy link
Author

neervanbiqs commented Oct 25, 2022

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

@dtmilano
Copy link
Owner

I would be helpful if you can replace pkg, act and uri in the previous script, run it and provide the timing output.

@neervanbiqs
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants