Cartucho / android-touch-record-replay

How to record and replay touchscreen events on an Android device.
Apache License 2.0
229 stars 49 forks source link

Hangs at the end of playback #12

Closed peterdk closed 5 years ago

peterdk commented 5 years ago

I am testing this approach ( on Android 9) to see if I can easily record video across different translations of my app. It works quite great, I can playback my session correctly, until the end. Then it suddenly hangs on a touch.

What I see is that at near the end I suddenly get a hanging touch. I see the touch indicator of Android (which I enabled) to keep indicating it is actively touching, but in the original recording I did continue.

Since this really seems to work otherwise, I hope this can be fixed. I will digg into it a bit more, to see where the issue arises.

Also, my touch device was not detected correctly, but manually figuring it out worked ok.

Other thing was that if I used 'adb shell [..] > local.txt' command to record touches, it would result in cut off file. I therefor just recorded on device using adb shell, and then issue commands to record to sd card.

peterdk commented 5 years ago

It seems to be caused by getevent not flushing after each event when redirected to file. I also have the issue when redirecting in adb shell itself. My solution for this, is to run adb shell and then run getevent without a redirection to file. After the recording is done, I just copy the whole terminal output and put that in a file. Now it works without issue!

Cartucho commented 5 years ago

Oh cool! I should update the Readme then with those instructions.

Do you think you could write here how you did it? So that I could put it in the README.

peterdk commented 5 years ago

What I basically do is: adb shell (gives me the shell) adb shell getevent -t /dev/input/event2 After I am done recording, I press CTRL-C Then I just select the whole output of the terminal and copy it to a file.

There probably is a better way to avoid output caching, but this works for me now. I read there is a 4k buffer when redirecting output to a file. When printing to console there is no buffer. Maybe there is a command to avoid the buffering, that would be easier and then the script would be useable again.

peterdk commented 5 years ago

I tested the script -t 0 q command, but that also resulted in missing data at the end. I also tested stdbuf from coreutils, but it also did not succeed. I am considering writing a simple C program that you can run on the adb shell that outputs the data to the /data/local/tmp/ without buffering.

peterdk commented 5 years ago

Found a solution! https://stackoverflow.com/questions/46233200/stop-buffering-of-adb-shell-output Instead of adb shell commands use adb exec-out commands. Now the buffering is gone when using the record_touch_events.sh and the last line is not partly missing.

Cartucho commented 5 years ago

I think we can close this issue.