Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
109.86k stars 10.55k forks source link

Everything appears working but no window opens (on X11, not Wayland) #4519

Open haunma opened 10 months ago

haunma commented 10 months ago

Environment

After using the scrcpy --otg trick to authorize my phone with adb (the phone screen is dead), I am able to run scrcpy. The default codec fails with java.lang.IllegalStateException in MediaCodec, but the output of scrcpy --list-encoders gives

    --video-codec=h264 --video-encoder='OMX.qcom.video.encoder.avc'
    --video-codec=h264 --video-encoder='c2.android.avc.encoder'
    --video-codec=h264 --video-encoder='OMX.google.h264.encoder'
    --video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc'
    --video-codec=h265 --video-encoder='c2.android.hevc.encoder'

and some of these are working. Or at least, they seem to be working. I get no errors or problems indicated in the scrcpy output even at "verbose" level, but no window opens. Typical output is

$ scrcpy --video-codec=h264 --video-encoder='OMX.google.h264.encoder' --no-audio -m1024
scrcpy 2.1.1 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  ZY224D2XM8                      device  Moto_Z_Play
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 111.5 MB/s (56995 bytes in 0.000s)
[server] INFO: Device: [Motorola] Motorola Moto Z Play (Android 11)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 23.3.0
INFO: Trilinear filtering enabled
INFO: Texture: 576x1024

I have tried adb shell screenrecord /sdcard/file.mp4 and that works---at least sometimes. It only seems to work when I run it right after unlocking the phone (with fingerprint sensor), otherwise I get a zero length file. I try to run scrcpy the same way but still no luck. Tried all the codecs. Tried various resolutions. Same result: apparent success in every respect except no video.

Also, scrcpy --video-codec=h264 --video-encoder='OMX.google.h264.encoder' --no-audio --record=file.mkv --no-playback seems to work when run but the video file is always zero length. I initially thought the problem could be with my tiling window manager but this seems to indicate that there really is no encoded video coming through the pipe. Correct?

rom1v commented 10 months ago

Yes, the problem is on the device, it means that MediaCodec does not produce any frame for some reason.

haunma commented 9 months ago

So that is basically the end of debugging, then? It just doesn't work for reasons unknown and unknow-able? This just reinforces my prejudice of Android as a steaming pile of **** that we basically treat as non-deterministic because almost nobody understands it deeply enough to problem-solve in the traditional sense :(

vidoardes commented 6 months ago

This is a Wayland / Scrpy problem and has nothing to do with Android. You can work round it by calling SDL_VIDEODRIVER=x11 scrcpy to force it back to X11.

There is already an issue about it here: https://github.com/Genymobile/scrcpy/issues/3431

haunma commented 6 months ago

This is a Wayland / Scrpy problem and has nothing to do with Android.

I usually try not to be snarky, but, wow, did you actually read the subject line on this bug report? I am using X, not Wayland. So unless there is a different bug in scrcpy, this does in fact appear to be an Android problem.

rom1v commented 6 months ago

@haunma Btw, does it work with screenrecord?

adb shell screenrecord /sdcard/file.mp4
adb pull /sdcard/file.mp4
haunma commented 6 months ago

@rom1v, as mentioned in the initial bug report, it is hit or miss. I was able to get a brief recording a couple of times, but it doesn't always work, often leaving a zero-length file.

My phone is old (Moto Z Play) and running LineageOS Android 18.1. I imagine there is something odd about it. Chalk it up to Android fragmentation? Anyway, my use case for scrcpy has passed, for now. Maybe next time I need something like that I will give it another go.

If you're reasonably confident the issue is on the device, I have no objections to closing this.