Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
111.82k stars 10.7k forks source link

v1.19, Google Pixel 4a (Android 12), Linux Mint Uma -> Segmentation fault #2763

Open dbolser opened 3 years ago

dbolser commented 3 years ago

I'm trying version 1.19 using the Dockerfile here: https://github.com/dbolser/scrcpy-docker/blob/feature/scrcpy-v1.19/Dockerfile

Used as described here: https://github.com/pierlon/scrcpy-docker

However, I'm getting the following error:

docker run --rm -i -t --privileged -v /dev/bus/usb:/dev/bus/usb -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY scrcpy:intel
/ # adb devices -l
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
0A171JEC219692         unauthorized usb:1-4 transport_id:1

/ # adb devices -l
List of devices attached
0A171JEC219692         device usb:1-4 product:sunfish model:Pixel_4a device:sunfish transport_id:1

/ # scrcpy  
INFO: scrcpy 1.19 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 215.9 MB/s (37330 bytes in 0.000s)
[server] INFO: Device: Google Pixel 4a (Android 12)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 21.2.5 (git-53b2b224dc)
INFO: Trilinear filtering enabled
INFO: Initial texture: 1080x2336
Segmentation fault (core dumped)
/ #  

The correct screen of my phone appears for a second before the core dump

rom1v commented 3 years ago

Replace here:

RUN cd scrcpy && meson x --buildtype release --strip -Db_lto=true -Dprebuilt_server=/scrcpy-server

by

RUN cd scrcpy && meson x --buildtype debug -Db_sanitize=address -Dprebuilt_server=/scrcpy-server

You'll get a stacktrace on segfault. That will help.

rom1v commented 3 years ago

Refs #1896.

dbolser commented 2 years ago

Thanks for putting this right in the Dockerfile for me. I found I had to remove -Db_sanitize=address as I couldn't find a way to install libsanitize-devel under alpine.

However, the result doesn't add much info:

docker run --rm -i -t --privileged -v /dev/bus/usb:/dev/bus/usb -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY scrcpy:debug-intel
/ # adb devices -l
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
0A171JEC219692         unauthorized usb:1-4 transport_id:1

/ # adb devices -l
List of devices attached
0A171JEC219692         device usb:1-4 product:sunfish model:Pixel_4a device:sunfish transport_id:2

/ # scrcpy 
INFO: scrcpy 1.19 <https://github.com/Genymobile/scrcpy>
DEBUG: Using server: /usr/local/share/scrcpy/scrcpy-server
/usr/local/share/scrcpy/scrcpy-server:...ed. 205.6 MB/s (37330 bytes in 0.000s)
DEBUG: Screensaver enabled
[server] INFO: Device: Google Pixel 4a (Android 12)
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
[server] DEBUG: Using encoder: 'c2.qti.avc.encoder'
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 21.2.5 (git-53b2b224dc)
INFO: Trilinear filtering enabled
INFO: Initial texture: 1080x2336
DEBUG: Starting stream thread
Segmentation fault (core dumped)
/ # [server] DEBUG: Controller stopped
[server] DEBUG: Screen streaming stopped
[server] DEBUG: Device message sender stopped

Looking for the core dump file, I found /tmp/adb.0.log:

/tmp # cat adb.0.log 
--- adb starting (pid 9) ---
adb I 11-12 11:20:12     9     9 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-12 11:20:12     9     9 main.cpp:63] Version 31.0.3-android-tools
adb I 11-12 11:20:12     9     9 main.cpp:63] Installed as /usr/bin/adb
adb I 11-12 11:20:12     9     9 main.cpp:63] 
adb I 11-12 11:20:12     9     9 auth.cpp:417] adb_auth_init...
adb I 11-12 11:20:12     9     9 auth.cpp:220] User key '/root/.android/adbkey' does not exist...
adb I 11-12 11:20:12     9     9 auth.cpp:64] generate_key(/root/.android/adbkey)...
adb I 11-12 11:20:12     9     9 auth.cpp:152] loaded new key from '/root/.android/adbkey' with fingerprint xxx
adb I 11-12 11:20:12     9     9 auth.cpp:392] adb_auth_inotify_init...
adb I 11-12 11:20:15     9    14 transport.cpp:333] 0A171JEC219692: read thread spawning
adb I 11-12 11:20:15     9    15 transport.cpp:305] 0A171JEC219692: write thread spawning
adb I 11-12 11:20:15     9     9 transport.cpp:1596] fetching keys for transport 0A171JEC219692
adb I 11-12 11:20:15     9     9 auth.cpp:469] Calling send_auth_response
adb I 11-12 11:20:15     9     9 auth.cpp:436] Calling send_auth_publickey
adb I 11-12 11:21:00     9    14 transport.cpp:337] 0A171JEC219692: read failed: Cannot send after socket shutdown
adb I 11-12 11:21:00     9    14 transport.cpp:1198] 0A171JEC219692: connection terminated: read failed
adb I 11-12 11:21:00     9     9 adb.cpp:172] 0A171JEC219692: offline
adb I 11-12 11:21:00     9     9 transport.cpp:911] destroying transport 0A171JEC219692
adb I 11-12 11:21:00     9     9 transport.cpp:405] BlockingConnectionAdapter(0A171JEC219692): stopping
adb I 11-12 11:21:00     9     9 transport.cpp:423] BlockingConnectionAdapter(0A171JEC219692): stopped
adb I 11-12 11:21:00     9     9 transport.cpp:292] BlockingConnectionAdapter(0A171JEC219692): destructing
adb I 11-12 11:21:00     9     9 transport.cpp:398] BlockingConnectionAdapter(0A171JEC219692): already stopped
adb I 11-12 11:21:04     9    17 transport.cpp:333] 0A171JEC219692: read thread spawning
adb I 11-12 11:21:04     9    18 transport.cpp:305] 0A171JEC219692: write thread spawning
adb I 11-12 11:21:04     9     9 transport.cpp:1596] fetching keys for transport 0A171JEC219692
adb I 11-12 11:21:04     9     9 auth.cpp:469] Calling send_auth_response
adb I 11-12 11:21:05     9     9 auth.cpp:436] Calling send_auth_publickey
adb I 11-12 11:21:12     9     9 adb.cpp:172] 0A171JEC219692: offline

Really sorry, but I can't find the core dump... ulimit -c says unlimited and I looked in /usr/local/bin (where scrcpy is).

dbolser commented 2 years ago

Ah, found it (with help from this, https://sigquit.wordpress.com/2009/03/13/the-core-pattern/). Attached. core.scrcpy.25.10dba39b4976.1636717692.gz

rom1v commented 2 years ago

Try to open gdb to print a backtrace:

export SCRCPY_SERVER_PATH=x/server/scrcpy-server
gdb x/app/scrcpy -c core.scrcpy.25.10dba39b4976.1636717692 -ex bt

(with the gunziped version of your core dump)

dbolser commented 2 years ago

Sorry, I'm not super 1337 at this stuff...

Within the Docker container:

/ # apk add gdb
export SCRCPY_SERVER_PATH=/usr/local/share/scrcpy/scrcpy-server
/ # ls -l $SCRCPY_SERVER_PATH
-rw-r--r--    1 root root 37330 Nov 12 11:15 /usr/local/share/scrcpy/scrcpy-server
/ # gdb /usr/local/bin/scrcpy -c core.scrcpy.48.7a0f6ab02408.1636972511 -ex bt
Error relocating /usr/bin/gdb: qsort_r: symbol not found

Ahh... I think I solved it with 'apk update; apk upgrade`.

/ # gdb /usr/local/bin/scrcpy -c /tmp/core.scrcpy.142.7a0f6ab02408.1636973739 -ex bt
GNU gdb (GDB) 11.1
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/bin/scrcpy...

warning: Can't open file /i915 (deleted) during file-backed mapping note processing

warning: Can't open file /memfd:xshmfence (deleted) during file-backed mapping note processing
[New LWP 142]
[New LWP 155]
[New LWP 148]
[New LWP 146]
[New LWP 153]
[New LWP 152]
[New LWP 156]
Core was generated by `scrcpy'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000000000 in ?? ()
--Type <RET> for more, q to quit, c to continue without paging--c
[Current thread is 1 (LWP 142)]
#0  0x0000000000000000 in ?? ()
#1  0x00007fdbcf0080f9 in ?? () from /usr/lib/libSDL2-2.0.so.0
#2  0x00007fdbcf00776f in ?? () from /usr/lib/libSDL2-2.0.so.0
#3  0x00007fdbcefd8865 in ?? () from /usr/lib/libSDL2-2.0.so.0
#4  0x00007fdbcef7cfc3 in ?? () from /usr/lib/libSDL2-2.0.so.0
#5  0x00007fdbcef7abc3 in ?? () from /usr/lib/libSDL2-2.0.so.0
#6  0x00007fdbceffc68f in ?? () from /usr/lib/libSDL2-2.0.so.0
#7  0x00007fdbceffcdad in ?? () from /usr/lib/libSDL2-2.0.so.0
#8  0x00007fdbceffdf0f in ?? () from /usr/lib/libSDL2-2.0.so.0
#9  0x00007fdbcef78d6d in ?? () from /usr/lib/libSDL2-2.0.so.0
#10 0x00007fdbcef78e57 in ?? () from /usr/lib/libSDL2-2.0.so.0
#11 0x000055a13f64ba32 in event_loop (s=0x55a13f6e0280 <scrcpy>, options=0x7ffd97180570) at ../app/src/scrcpy.c:180
#12 0x000055a13f64c306 in scrcpy (options=0x7ffd97180570) at ../app/src/scrcpy.c:417
#13 0x000055a13f642e09 in main (argc=1, argv=0x7ffd97180688) at ../app/src/main.c:92

Does that give you what you need?

Thank you!

rom1v commented 2 years ago

1 0x000055a13f64ba32 in event_loop (s=0x55a13f6e0280 , options=0x7ffd97180570) at ../app/src/scrcpy.c:180

On v1.19, it is the call to SDL_WaitEvent(): https://github.com/Genymobile/scrcpy/blob/228e2c15f44849032e9006dce1e0c47ae6e108ee/app/src/scrcpy.c#L180

But then you don't have the SDL symbols down the backtrace. Probably an SDL bug (related to a permission issue or something?)

dbolser commented 2 years ago

So I should compile and link a debugging version of SDL?

Else is there a known good SDL version?

Thank you so much for your help so far :-) I'm not sure how best to carry this forward.

On Mon, 15 Nov 2021 at 11:07, Romain Vimont @.***> wrote:

1 0x000055a13f64ba32 in event_loop (s=0x55a13f6e0280 , options=0x7ffd97180570) at ../app/src/scrcpy.c:180

On v1.19, it is the call to SDL_WaitEvent(): https://github.com/Genymobile/scrcpy/blob/228e2c15f44849032e9006dce1e0c47ae6e108ee/app/src/scrcpy.c#L180

But then you don't have the SDL symbols down the backtrace. Probably an SDL bug (related to a permission issue or something?)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Genymobile/scrcpy/issues/2763#issuecomment-968785951, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA7NE3HZNNFKE5KZMAB7LDUMDSVXANCNFSM5H2JCQPQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

dbolser commented 2 years ago

I wondered if the permission issue you mentioned may be to do with Ctrl-c/Ctrl-v etc. so I tried scrcpy -n, however that failed in the exact same way. BUT, trying scrcpy -N -r blah.mkv 'worked' correctly. Of course I couldn't see my screen, but I could copy the recording and it was an accurate recording (up to Ctrl-c in the terminal).

Perhaps this is just an docker / X permission issue?

I didn't think this was the case because I do see the correct screen appear for an instant at startup. I would simply expect an X error on the command line if it were an X permission thing...

Anyway, suggestions welcome!

dbolser commented 2 years ago

Host:

Graphics:
  Device-1: Intel UHD Graphics 620 driver: i915 v: kernel 
  Display: x11 server: X.Org 1.20.11 driver: modesetting 
  unloaded: fbdev,vesa resolution: 1680x1050~60Hz, 1920x1080~60Hz 
  OpenGL: renderer: Mesa Intel UHD Graphics 620 (WHL GT2) v: 4.6 Mesa 21.0.3 
skauss commented 2 years ago

I have the same problem on a Pixel 4a Android 12 on Pixel 3a with Android 11 scrcpy 1.16 still work.

2021-11-24 14:51:27.773 scrcpy[31103:3990848] INFO: scrcpy 1.16 <https://github.com/Genymobile/scrcpy>
/usr/local/Cellar/scrcpy/1.16/share/scrcpy/scrcpy-serv...e pushed, 0 skipped. 34.6 MB/s (33622 bytes in 0.001s)
[server] INFO: Device: Google Pixel 4a (5G) (Android 12)
2021-11-24 14:51:28.021 scrcpy[31103:3990848] INFO: Renderer: metal
2021-11-24 14:51:28.024 scrcpy[31103:3990848] INFO: Initial texture: 1080x2336
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.AssertionError: java.lang.reflect.InvocationTargetException
    at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:75)
    at com.genymobile.scrcpy.ScreenEncoder.setDisplaySurface(ScreenEncoder.java:216)
    at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:86)
    at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:55)
    at com.genymobile.scrcpy.Server.scrcpy(Server.java:76)
    at com.genymobile.scrcpy.Server.main(Server.java:225)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:73)
    ... 7 more
Caused by: java.lang.IllegalArgumentException: displayToken must not be null
    at android.view.SurfaceControl$Transaction.setDisplaySurface(SurfaceControl.java:3145)
    at android.view.SurfaceControl.setDisplaySurface(SurfaceControl.java:2214)
    ... 9 more
rom1v commented 2 years ago

I have the same problem on a Pixel 4a Android 12

No, this is not the same problem at all. Your error is #2129.

You must use a version of scrcpy >= 1.18 for Android 12.

JaldeepAsodariya commented 2 years ago

Hello @rom1v Thanks for the Android 12 support. I'm currently using scrcpy 1.16 . Do we any specific command for upgrade to scrcpy 1.18?

rom1v commented 2 years ago

https://github.com/Genymobile/scrcpy/blob/master/BUILD.md#simple

edaubert commented 2 years ago

I wondered if the permission issue you mentioned may be to do with Ctrl-c/Ctrl-v etc. so I tried scrcpy -n, however that failed in the exact same way. BUT, trying scrcpy -N -r blah.mkv 'worked' correctly. Of course I couldn't see my screen, but I could copy the recording and it was an accurate recording (up to Ctrl-c in the terminal).

Perhaps this is just an docker / X permission issue?

I didn't think this was the case because I do see the correct screen appear for an instant at startup. I would simply expect an X error on the command line if it were an X permission thing...

Anyway, suggestions welcome!

I have the same issue but could not find a way to fix it.

Did you find something ?