Skip to content

Keyboard presses are being sent out too fast(repetititve) #109

Closed

Description

@wieuwzak

Hi,

When using chat apps through scrcpy, one enter key press seems to send multiple enter key presses.
For instance, when I press enter in whatsapp, my message gets sent and the typing bar emptied itself. But also tries to send out a message that contains no letters. This gives me an annoying toast that says I cant send blank messages. Happens almost on every enter press. Looks like it sends multiple enter presses while it should be one.

Activity

  1. rom1v commented on Apr 2, 2018

    @rom1v
    Collaborator

    one enter key press seems to send multiple enter key presses.

    I am not able to reproduce for now.

  2. rom1v commented on Apr 3, 2018

    @rom1v
    Collaborator

    If you press enter in any text editor on your computer, does it sometimes generate several newlines?

    What is your OS (Linux, Windows, macOS…)?

  3. EnderHDMC commented on Apr 9, 2018

    @EnderHDMC

    You can test this in games. Minecraft is a good example. If you hold W, instead of it being one continuous keystroke, it seems to send it as many short keystrokes, this makes it impossible to walk properly. The character walks for a few milliseconds, stops, and repeats this until you let go of W.

    I didn't get the same issue on Whatsapp though, just thought this would probably be a related issue.

    System (from uname -a):
    Linux DarkEnder 4.15.0-kali2-amd64 #1 SMP Debian 4.15.11-1kali1 (2018-03-21) x86_64 GNU/Linux

    Phone (from Droid Info): Sony Xperia X Compact
    Model: F5321
    Build Number 34.3.A.0.252
    OS Version: M MR1 (7.1.1)
    SDK: 25

  4. rom1v commented on Apr 9, 2018

    @rom1v
    Collaborator

    OK. So the solution is probably to forward the repeat field of SDL_KeyboardEvent, and inject it on the device.

  5. wieuwzak commented on Apr 9, 2018

    @wieuwzak
    Author

    My keyboard functions as normal in all other situations. I have "press enter to send message" option enabled in Whatsapp. I just feel like we are missing a basic function where repetitive keystrokes aren't being issued too fast. For example when long pressing enter in a normal situation, there's a time limit before a keystroke is being noticed as repetitive. But when in scrcpy I feel like that time limit is non existent? Rom1v thank you for your solution and work!

  6. rom1v commented on Oct 4, 2018

    @rom1v
    Collaborator

    Could you test with v1.4 please? Maybe #87 fixes your problem as a side-effect.

  7. rom1v commented on Oct 5, 2018

    @rom1v
    Collaborator

    @maiconandsilva Thank you for your feedback.

    the issue now is typing latin characters like áãàâ or óôòõ

    The fact that these chars are duplicated is still the same issue: it seems that there is a problem in your Android version either to convert a String to a list of events, or the way the events generated are interpreted.

    If you (or someone having a device with the same problem) can figure out if something is wrong with the result of charMap.getEvents(chars).

    The fact that the accents or tilde are not added is a separate issue, and probably comes from your Android keyboard not supporting "diacritical dead key characters" (see Handle accented characters).

  8. Mehardeep commented on Aug 28, 2019

    @Mehardeep

    SDL generates fake repeated keypresses if you hold a key long enough. This is used mostly for text input.
    The original key press has .repeat == 0, and fake presses have .repeat == 1
    SDL_KeyboardEvent *event
    if(event->repeat ==0){
    }

  9. rom1v commented on Apr 9, 2020

    @rom1v
    Collaborator

    Does it stlil happen on latest version?

  10. StephenW789 commented on May 29, 2020

    @StephenW789

    @rom1v I think this issue still occurs. I tested on both the v1.12 and v1.14 in terms of typing into google docs, and if a key is held down long enough, it does seem to generate fake repeated keypresses (maybe that is where the lag comes from).

    I think this is the issue I encountered in Minecraft as well. Once I hold down a key for an extended period of time, the character will continue moving for several seconds even after the key is released. It has nothing to do with the screen mirroring lag between computer and phone.

    Is there anyway I can fix it/reduce performance issues?

  11. rom1v commented on May 29, 2020

    @rom1v
    Collaborator

    Could you test with this change:

    diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java
    index 349486c..9f1b69f 100644
    --- a/server/src/main/java/com/genymobile/scrcpy/Device.java
    +++ b/server/src/main/java/com/genymobile/scrcpy/Device.java
    @@ -164,7 +164,7 @@ public final class Device {
         }
     
         public boolean injectEvent(InputEvent event) {
    -        return injectEvent(event, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
    +        return injectEvent(event, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
         }
     
         public boolean injectKeyEvent(int action, int keyCode, int repeat, int metaState) {

    or this one:

    diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java
    index 349486c..eb877e9 100644
    --- a/server/src/main/java/com/genymobile/scrcpy/Device.java
    +++ b/server/src/main/java/com/genymobile/scrcpy/Device.java
    @@ -164,7 +164,7 @@ public final class Device {
         }
     
         public boolean injectEvent(InputEvent event) {
    -        return injectEvent(event, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
    +        return injectEvent(event, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT);
         }
     
         public boolean injectKeyEvent(int action, int keyCode, int repeat, int metaState) {
  12. 1 remaining item

  13. rom1v commented on May 29, 2020

    @rom1v
    Collaborator

    No, you must apply the changes and build locally.

    Anyway, here is the server (to replace in v1.14) with WAIT_FOR_FINISH:

    • scrcpy-server
      SHA256: a9d56b4b8914ad949f5f191f01a983c6a43df0c88b7ba4973881017bf851c7f3
  14. StephenW789 commented on May 29, 2020

    @StephenW789

    @rom1v I have tested it on google docs on v1.14

    It seems like the words continue to lag during typing. Visually, after the changes, there is a difference in typing, but not much improvement.

    For the file you suggested, did you provide the "WAIT_FOR_FINISH" or the "WAIT_FOR_RESULT"?

  15. StephenW789 commented on May 29, 2020

    @StephenW789

    @rom1v May you also supply the server for v1.12 for both "WAIT_FOR_FINISH" and "WAIT_FOR_RESULT"? Perhaps its a combination of both the rendering GUI + the keyboard issue.

  16. rom1v commented on May 29, 2020

    @rom1v
    Collaborator

    No, that was just a quick test, I don't think it has any impact. And there is no rendering issue on v1.14 in #1441.

  17. StephenW789 commented on May 29, 2020

    @StephenW789

    Since we already tested "WAIT_FOR_FINISH", would the "WAIT_FOR_RESULT" improve performance instead?

    I took a look at the java code on github, and it seemed like most of these changes are simply constant values in the Java InputManager class. Do you think there is something else that's slowing this down?

  18. rom1v commented on May 29, 2020

    @rom1v
    Collaborator

    The slowdown is probably in the Android rom itself when we send too many events too quickly.

  19. StephenW789 commented on May 29, 2020

    @StephenW789

    I see. Is there anyway this can be fixed? Or is this likely an issue on the android's part?

  20. rom1v commented on May 29, 2020

    @rom1v
    Collaborator

    I don't know. It greatly depends on the device. On my device I have no problem.

  21. StephenW789 commented on May 29, 2020

    @StephenW789

    What is your device? Do you have any settings on?

  22. StephenW789 commented on May 29, 2020

    @StephenW789

    I have a motog6, 2GB of RAM, are you using a newer model?

  23. StephenW789 commented on May 30, 2020

    @StephenW789

    I tested this over wireless, thinking that it may be the data cable being slow, but the keyboard lag is still persistant.

    Under the developer options for my phone, I also reduced all three animation scales, forced GPU rendering, force 4x MSAA, hoping that it would improve my phone's performance, but did not fix the keyboard lag.

  24. StephenW789 commented on May 30, 2020

    @StephenW789

    I have noticed that when copy-pasting a long line of text in google docs, there is also a keyboard lag. Interestingly, the characters when pasted are typed out one by one on the display, rather than all at once.

  25. xeropresence commented on Jun 10, 2020

    @xeropresence
    Contributor

    No, you must apply the changes and build locally.

    Anyway, here is the server (to replace in v1.14) with WAIT_FOR_FINISH:

    • scrcpy-server
      SHA256: a9d56b4b8914ad949f5f191f01a983c6a43df0c88b7ba4973881017bf851c7f3

    Having this issue on my device, moto x4 running havoc-os. Using this scrcpy-server did not seem to effect keyboard inputs, but did effect touch events. Touch events that were genereated by clicking and dragging the mouse were greatly slowed down.

  26. rom1v commented on Oct 27, 2021

    @rom1v
    Collaborator

    There is an option --no-key-repeat since v1.15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions