-
Notifications
You must be signed in to change notification settings - Fork 297
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
Fix input text speed on Android #2027
base: main
Are you sure you want to change the base?
Conversation
Hey @tokou! Thanks a ton for taking a stab and fixing this very annoying problem. The speedup is amazing indeed, but I'm not sure if we want it, given that we want Maestro to behave like a normal user. Anyway, we could make this new behavior the default, and add a configuration option for I like all the changes you made in this PR, but I'm curious whether you know what's the change that actually fixed the problem? Was it the removal of that |
.fold(emptyList<Pair<List<Int>, Int>>()) { acc, elem -> | ||
if (acc.isEmpty() || acc.last().second != elem.second) acc + listOf(listOf(elem.first) to elem.second) | ||
else acc.dropLast(1) + listOf(acc.last().let { (it.first + listOf(elem.first)) to it.second }) |
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.
Let's add a comment explaining what this code does and/or simplify it.
I like the test that inputs the whole "Lorem ipsum...". If that test also used I'd like us to have this test in our I'll add such a screen to our demo app. |
Oh, and let's also add an entry to CHANGELOG.md |
Nice work on this! Some context on the delays added in the original implementation: We were seeing some issues where sometimes characters would be skipped. This was difficult to reproduce consistently, but we should ensure that this does not regress before making this the default behavior. |
@bartekpacia I added the comment. Hope it clears things up.
I think this is due to the rate of commands sent to The only potential issue is that the documentation of
— https://developer.android.com/reference/androidx/test/uiautomator/UiDevice#pressKeyCodes(int[],int) In practice, it seems to be working fine though. |
@bartekpacia Unfortunately, after adding the test on the demo app, I got some random failures when running it on my emulator. I think it's in part because of the demo app being a Flutter app that makes the issue happen more often. |
Hey @tokou is this PR ready for review? I see that you observed some random failures, let me know if you need help on this. |
Proposed changes
UiDevice#pressKeyCodes
with bunches of keyCodes instead ofUiDevice#pressKeyCode
with a single keyCode at a timeThread.sleep(75)
The speedup is amazing 🤩
Testing
maestro/maestro-client/src/main/java/maestro/drivers/AndroidDriver.kt
Line 72 in 6ac16c2
Issues fixed
Fixes #2005