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

Keyboard wont work after around 15 words typed in Messenger. #350

Closed
krooyakkers opened this issue Nov 21, 2018 · 11 comments
Closed

Keyboard wont work after around 15 words typed in Messenger. #350

krooyakkers opened this issue Nov 21, 2018 · 11 comments

Comments

@krooyakkers
Copy link

krooyakkers commented Nov 21, 2018

After around 15 words sometimes less, the keyboard stops being able to type letters, i press the letter and the curser doesnt move, it just blinks. I have to send the message and then start a new message to write anymore.Sometimes i cant even send it after. I have to exit and enter again.

ERROR: Exception on thread Thread[Thread-1,5,main]
java.lang.IllegalStateException: Buffer full, call next() to consume
	at com.genymobile.scrcpy.ControlEventReader.readFrom(ControlEventReader.java:34)
	at com.genymobile.scrcpy.DesktopConnection.receiveControlEvent(DesktopConnection.java:74)
	at com.genymobile.scrcpy.EventController.handleEvent(EventController.java:70)
	at com.genymobile.scrcpy.EventController.control(EventController.java:65)
	at com.genymobile.scrcpy.Server$1.run(Server.java:34)
	at java.lang.Thread.run(Thread.java:764)

THis is the error that just showed up when it stopped working. I dunno what to do with it.

@rom1v
Copy link
Collaborator

rom1v commented Nov 21, 2018

Thank you for your report.

What is your Android version?

I cannot reproduce the problem on my device. To help finding the root cause, could you please replace scrcpy-server.jar from your scrcpy v1.5 directory by this one, and try again:

scrcpy-server.jar
(SHA-256: 00d2852faeb8279dcde7d077a2368be664e1cfff27acfe6a7fe2bb456139c0bf)

It does not fix anything, but adds some interesting logs that might help to understand what goes wrong.
Please paste the logs here.


Precisely, here is the diff:

diff --git a/server/src/main/java/com/genymobile/scrcpy/ControlEventReader.java b/server/src/main/java/com/genymobile/scrcpy/ControlEventReader.java
index 83088b1..f3dcdef 100644
--- a/server/src/main/java/com/genymobile/scrcpy/ControlEventReader.java
+++ b/server/src/main/java/com/genymobile/scrcpy/ControlEventReader.java
@@ -29,18 +29,29 @@ public class ControlEventReader {
         return buffer.remaining() == rawBuffer.length;
     }
 
+    private void log(String msg) {
+        Ln.d(msg + ": " + buffer.position() + ", " + buffer.limit());
+    }
+
     public void readFrom(InputStream input) throws IOException {
+        Ln.d("=============");
+        log("#0");
         if (isFull()) {
             throw new IllegalStateException("Buffer full, call next() to consume");
         }
         buffer.compact();
+        log("#1");
         int head = buffer.position();
         int r = input.read(rawBuffer, head, rawBuffer.length - head);
+        Ln.d("r = " + r);
+        log("#2");
         if (r == -1) {
             throw new EOFException("Event controller socket closed");
         }
         buffer.position(head + r);
+        log("#3");
         buffer.flip();
+        log("#4");
     }
 
     public ControlEvent next() {

@krooyakkers
Copy link
Author

hmm, replacing that file actually fixed the problem. Its not doing it anymore. Weird. Thank you for your help

@rom1v
Copy link
Collaborator

rom1v commented Nov 22, 2018

This is not expected. Could you recheck with the original scrcpy-server.jar, please?

@krooyakkers
Copy link
Author

I deleted it. Yeah it stopped. Haven't had a problem since. I really like being able to use my comp to type messages. Pain in the butt to get messages and do it on my phone. Hopefully it gets more support and is officially added to repositories

@rom1v
Copy link
Collaborator

rom1v commented Nov 22, 2018

I deleted it.

It's in the official v1.5 release :) If you can reproduce it, I'm interested.

@0xAdk
Copy link

0xAdk commented Jan 22, 2019

Hi, I also have this problem the only differance being that after I click/drag with my mouse I get the exeption. Sadly unlike OP when I use v1.5 scrcpy-server.jar I get an error.

/usr/share/scrcpy/scrcpy-server.jar: 1 file pushed. 1.3 MB/s (19186 bytes in 0.015s)
ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalArgumentException: Crop must contains 4 values separated by colons: "-"
 at com.genymobile.scrcpy.Server.parseCrop(Server.java:91)
 at com.genymobile.scrcpy.Server.createOptions(Server.java:72)
 at com.genymobile.scrcpy.Server.main(Server.java:108)
 at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
 at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:301)

Reinstalling the v1.6 scrcpy-server.jar and running scrcpy I encounted the same error I was getting before

/usr/share/scrcpy/scrcpy-server.jar: 1 file pushed. 3.3 MB/s (19346 bytes in 0.006s)
INFO: Initial texture: 1920x1080
ERROR: Exception on thread Thread[Thread-1,5,main]
java.nio.BufferUnderflowException
 at java.nio.Buffer.nextGetIndex(Buffer.java:493)
 at java.nio.HeapByteBuffer.getShort(HeapByteBuffer.java:241)
 at com.genymobile.scrcpy.ControlEventReader.readPosition(ControlEventReader.java:138)
 at com.genymobile.scrcpy.ControlEventReader.parseMouseControlEvent(ControlEventReader.java:112)
 at com.genymobile.scrcpy.ControlEventReader.next(ControlEventReader.java:62)
 at com.genymobile.scrcpy.DesktopConnection.receiveControlEvent(DesktopConnection.java:89)
 at com.genymobile.scrcpy.EventController.handleEvent(EventController.java:66)
 at com.genymobile.scrcpy.EventController.control(EventController.java:61)
 at com.genymobile.scrcpy.Server$1.run(Server.java:41)
 at java.lang.Thread.run(Thread.java:761)

After the error I can still see my phone's screen and it continues to update but none of my clicks register after that point

@rom1v rom1v added the bug label Jan 22, 2019
rom1v added a commit that referenced this issue Jan 22, 2019
Commit fefb981 modified mouse events
serialization. The server-side parsing was updated to correctly read the
position, but the expected size of these events was not updated.

As a result, the server might try to parse incomplete events, leading
to BufferUnderflowException.

Fixes
<#350 (comment)>.
@rom1v
Copy link
Collaborator

rom1v commented Jan 22, 2019

Sadly unlike OP when I use v1.5 scrcpy-server.jar I get an error.

This is expected (current master is v1.6).

Reinstalling the v1.6 scrcpy-server.jar and running scrcpy I encounted the same error I was getting before

OK, thank you for your report. This is not the same error. This bug has been introduced between v1.5 and v1.6, and should be fixed on dev: b35733e

The fix modifies the server, so you need not to use the prebuilt server to test. If you encounter problems, please tell me, I'll provide a new .jar.

@rom1v
Copy link
Collaborator

rom1v commented Jun 25, 2019

Does it still happen?

@rom1v rom1v closed this as completed Apr 9, 2020
@alfeugds
Copy link

alfeugds commented Nov 10, 2020

Hello! I have the same java.nio.BufferUnderflowException exception after some moments of scrcpy opened:

image

It usually happens when I'm interacting with the mouse, or if I let the screen opened for some minutes.

Android device: Xiaomi Mi A2 Lite
Android version: 10, October 2020 update

Do you think it is related to this same issue?

@rom1v
Copy link
Collaborator

rom1v commented Nov 10, 2020

v1.6 is very old. Use the latest version (v1.16).

@alfeugds
Copy link

My bad. I didn't realize that I was using a version that I built in my machine a while ago.
I'll do a clean install

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

No branches or pull requests

4 participants