scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Fedora 42 Workstation (Wayland) - Occasional freezing

Open strangeh21 opened this issue 7 months ago • 11 comments

Please read the prerequisites to run scrcpy.

Also read the FAQ and check if your issue already exists.

Environment

  • OS: Linux - Fedora 42 Workstation - Gnome Wayland
  • Scrcpy version: 3.2
  • Installation method: sudo dnf copr enable zeno/scrcpy && sudo dnf install scrcpy
  • Device model: Nothing Phone 2a.
  • Android version: 15

Describe the bug

Occasional freezing that lasts 30-90 seconds. There's no output from the console during this time, phone continues working, only scrcpy freezes. From console, when it continues working again there's many entries that all say WARN: Could not request 'inject keycode'

If I try to exit the console using CTRL+C while scrcpy is frozen, this error appears:

ERROR: Could not post SC_EVENT_DEVICE_DISCONNECTED event: Event queue is full (65535 events)
ERROR: Could not post SC_EVENT_DEVICE_DISCONNECTED event: Event queue is full (65535 events)
ERROR: Could not post SC_EVENT_DEVICE_DISCONNECTED event: Event queue is full (65535 events)

While I cannot say for certain, it seems the issue appears sooner the more I do on the device, which seems to indicate an issue with the clearing the queue of inputs to the device.

I have tried the following: Making sure libdecor is installed and setting the variable SDL_VIDEODRIVER=wayland.

Sadly this did not solve the issue. I thought it did, but it just took considerably longer before the issue reappeared. Collecting adb logcat now.

strangeh21 avatar May 22 '25 12:05 strangeh21

Attached adb logcat file. It took about 10 minutes before it froze. I have removed the 10 minutes prior to reduce the size of the log file.

adb_logcat.txt

I cannot say exactly when it froze, but it's around the 16:00 mark.

It unfroze when you see the spam of 05-22 16:02:37.296 1692 2893 D KeyCombinationManager: interceptKeyLocked() keyCode:62 count:0 down:true interactive:true eventTime:8643283 mDownTimes={62=8643169}

strangeh21 avatar May 22 '25 13:05 strangeh21

Event queue is full (65535 events)

Looks like a SDL issue.

What SDL version do you use? (run scrcpy --version)

rom1v avatar May 22 '25 13:05 rom1v

Event queue is full (65535 events)

Looks like a SDL issue.

What SDL version do you use? (run scrcpy --version)

Should be the most up to date. If it helps, I'm trying on a 2nd device now to collect logcat entry, which has significantly less logcat entries. Will be able to tell if it's device, or computer related.

$ scrcpy --version
scrcpy 3.2 <https://github.com/Genymobile/scrcpy>

Dependencies (compiled / linked):
 - SDL: 2.32.52 / 2.32.56
 - libavcodec: 61.19.101 / 61.19.101
 - libavformat: 61.7.100 / 61.7.100
 - libavutil: 59.39.100 / 59.39.100
 - libavdevice: 61.3.100 / 61.3.100
 - libusb: - / 1.0.28

strangeh21 avatar May 22 '25 13:05 strangeh21

Will be able to tell if it's device, or computer related.

Given that the SDL event queue is full, it is a problem on the client side. Even if the device was not responsive, the client events should still be processed (sending the events is performed from a separate thread in scrcpy). So I'd say there's a problem between SDL and Wayland.

rom1v avatar May 22 '25 13:05 rom1v

Will be able to tell if it's device, or computer related.

Given that the SDL event queue is full, it is a problem on the client side. Even if the device was not responsive, the client events should still be processed (sending the events is performed from a separate thread in scrcpy). So I'd say there's a problem between SDL and Wayland.

Is there anything I can troubleshoot with that?

I believe I have narrowed down the issue to using the space bar while holding down mouse button (2nd touch on screen)

adb_log_opt6.txt

). Although there's an error in the adb log: 05-22 17:10:36.966 1256 6377 D InputDispatcher: Touch mode switch rejected, caller (pid=0, uid=10164) doesn't own the focused window nor none of the previously interacted window

If I press the space bar 3-5 times, then it crashes. Error shows up on 1st space bar press. Shown in the logcat file happening a few times.

Is this issue related to scrcpy and if so, can I do anything to help further discover where the issue is or how to solve it?

strangeh21 avatar May 22 '25 14:05 strangeh21

InputDispatcher: Touch mode switch rejected, caller (pid=0, uid=10164) doesn't own the focused window nor none of the previously interacted window

This message is produced by Android (since you got it in the logcat).

But I could not understand how this could cause Event queue is full (65535 events) on the client side. That might be two different issues (or I would be surprised).

If I press the space bar 3-5 times, then it crashes.

What crashes? The client or the device?

rom1v avatar May 22 '25 14:05 rom1v

InputDispatcher: Touch mode switch rejected, caller (pid=0, uid=10164) doesn't own the focused window nor none of the previously interacted window

This message is produced by Android (since you got it in the logcat).

But I could not understand how this could cause Event queue is full (65535 events) on the client side. That might be two different issues (or I would be surprised).

If I press the space bar 3-5 times, then it crashes.

What crashes? The client or the device?

scrcpy is what crashes/freezes. It looks like it also bugs the android device that was being interacted with to some extent as well. Like whatever key was being pressed is now "stuck" and cannot be used even on the android device. Gets solved by exiting scrcpy / disconnecting adb or waiting for scrcpy to unfreeze, at which point, I can "unstick" the key by pressing it within scrcpy.

strangeh21 avatar May 22 '25 18:05 strangeh21

scrcpy is what crashes/freezes.

OK, that makes sense if the Event queue is full (65535 events). There's probably a deadlock in the SDL event queue.

Can you reproduce on a non-wayland system?

rom1v avatar May 22 '25 18:05 rom1v

scrcpy is what crashes/freezes.

OK, that makes sense if the Event queue is full (65535 events). There's probably a deadlock in the SDL event queue.

Can you reproduce on a non-wayland system?

I logged in with xorg on the same system and am unable to reproduce the error. I can confirm it is absolutely a wayland specific issue.

strangeh21 avatar May 22 '25 19:05 strangeh21

Thank you. Then you should report to SDL I guess (mention that it's SDL2). The important message is Event queue is full (65535 events).

rom1v avatar May 22 '25 19:05 rom1v

Thank you for the help rom1v! Will report to SDL. Before I do, I just wanted to double check one thing. The error about Event queue is full only happens on 1 device. It does not happen on the 2nd device. There the only error I see is InputDispatcher: Touch mode switch rejected, caller (pid=0, uid=10164) doesn't own the focused window nor none of the previously interacted window Which is a permissions error. This error is not present on the 1st device, where sadly there's too much spam within logcat to tell exactly what is the error, but scrcpy seems to freeze around that Event queue is full error.

Are we certain the error is SDL related?

EDIT: Apologies. I was looking at logcat. You were talking about the error showing in scrcpy. Unfortunately this error is also not shown on both devices.

Device 1 (With event full error) - Nothing Phone 2a Android 15 scrcpylog_np2a.txt

WARN: Could not disable minimize on focus loss
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 75.1 MB/s (90888 bytes in 0.001s)
[server] INFO: Device: [Nothing] Nothing A142 (Android 15)
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Using video encoder: 'c2.mtk.avc.encoder'
[server] DEBUG: Display: using DisplayManager API
ERROR: Could not post SC_EVENT_NEW_FRAME event: Event queue is full (65535 events)
ERROR: Could not post SC_EVENT_DEMUXER_ERROR event: Event queue is full (65535 events)
WARN: Could not request 'inject keycode'

Device 2 (Without event queue full error) - Oneplus 6T Android 13 scrcpylog_opt6.txt

WARN: Could not disable minimize on focus loss
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 92.1 MB/s (90888 bytes in 0.001s)
[server] INFO: Device: [OnePlus] OnePlus ONEPLUS A6013 (Android 13)
[server] DEBUG: Using video encoder: 'OMX.qcom.video.encoder.avc'
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Display: using SurfaceControl API
WARN: Could not request 'inject keycode'

Device 3 - Oneplus 6T Android 14 scrcpylog_opt6_crdroid.txt

WARN: Could not disable minimize on focus loss
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 105.5 MB/s (90888 bytes in 0.001s)
[server] INFO: Device: [OnePlus] OnePlus ONEPLUS A6013 (Android 14)
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Using video encoder: 'OMX.qcom.video.encoder.avc'
[server] DEBUG: Display: using DisplayManager API
WARN: Could not request 'inject keycode'

Device 4 - Alcatel 1S Android 11 scrcpylog_alcatel1s.txt

WARN: Could not disable minimize on focus loss
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 76.8 MB/s (90888 bytes in 0.001s)
[server] INFO: Device: [unknown] Phh Phh-Treble vanilla (Android 11)
[server] DEBUG: Using video encoder: 'OMX.MTK.VIDEO.ENCODER.AVC'
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Display: using SurfaceControl API
WARN: Could not request 'inject keycode'

strangeh21 avatar May 22 '25 19:05 strangeh21

I mentioned in the linked SDL issue, but the symptoms sound like a timestamp handling bug in older SDL3 versions, which caused excessive key repeat events to be enqueued. It is fixed in the current 3.2.16 release, however, the Fedora repos are still providing the older 3.2.12 release, where the bug is present.

Updating to the latest SDL3 + sdl2-compat should fix this.

Kontrabant avatar Jun 25 '25 14:06 Kontrabant

Fedora recently updated their SDL3 package to 3.2.16. Can you retry, please?

https://github.com/libsdl-org/SDL/issues/13272#issuecomment-3049656293

rom1v avatar Jul 09 '25 08:07 rom1v