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

encoder problem or hardware problem #3120

Open
fuch123 opened this issue Mar 16, 2022 · 8 comments
Open

encoder problem or hardware problem #3120

fuch123 opened this issue Mar 16, 2022 · 8 comments

Comments

@fuch123
Copy link

fuch123 commented Mar 16, 2022

  • [ yes ] I have read the FAQ.
  • [ yes ] I have searched in existing issues.

Environment

  • OS: [Raspbian Linux 11 (Debian)]
  • scrcpy version: [1.23(the newest one)]
  • installation method: [manual build]
  • device model: xiaomi 10S
  • Android version: [12]

Describe the bug
I installed raspbian Linux on Microsoft's surfacert
Then I want to use surfacert as a touch screen
Surfacert is an arm-32-bit NVIDIA processor
Connect my Xiaomi 10s mobile phone (Android 12)
Illegal command error while executing command
After reading the FAQ and other issues, they failed to solve the problem
I tried scrcpy - m1024, -m800, -m600, but all failed
But it's strange that this mobile phone can work normally on windows 10-64 bit system through scrcpy-1.23
The problem should be located on the surfacert device. It seems that it should be the problem of the encoder
I don't know if it can be solved. I hereby ask a question.

Terminal outputs

pi@raspberrypi:~/scrcpy $ scrcpy 
scrcpy 1.23 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 1.8 MB/s (41123 bytes in 0.022s)
[server] INFO: Device: Xiaomi M2102J2SC (Android 12)
INFO: Renderer: opengl
INFO: OpenGL version: 3.1 Mesa 20.3.5
INFO: Trilinear filtering enabled
Illegal instruction
pi@raspberrypi:~/scrcpy $ 
pi@raspberrypi:~/scrcpy $ scrcpy --encoder _
scrcpy 1.23 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 3.8 MB/s (41123 bytes in 0.010s)
[server] INFO: Device: Xiaomi M2102J2SC (Android 12)
[server] ERROR: Exception on thread Thread[main,5,main]
com.genymobile.scrcpy.InvalidEncoderException: There is no encoder having name '_"
	at com.genymobile.scrcpy.ScreenEncoder.createCodec(ScreenEncoder.java:222)
	at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:83)
	at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:74)
	at com.genymobile.scrcpy.Server.scrcpy(Server.java:101)
	at com.genymobile.scrcpy.Server.main(Server.java:331)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:363)
[server] ERROR: Try to use one of the available encoders:
[server] ERROR:     scrcpy --encoder 'OMX.qcom.video.encoder.avc'
[server] ERROR:     scrcpy --encoder 'c2.android.avc.encoder'
[server] ERROR:     scrcpy --encoder 'OMX.google.h264.encoder'
[server] ERROR:     scrcpy --encoder 'c2.qti.avc.encoder'
INFO: Renderer: opengl
INFO: OpenGL version: 3.1 Mesa 20.3.5
INFO: Trilinear filtering enabled
Illegal instruction
pi@raspberrypi:~/scrcpy $ 
pi@raspberrypi:~/scrcpy $ uname -a
Linux raspberrypi 5.16.0-rc3-next-20211203-Open-Surface-RT-g69355ae4d8f9 #63 SMP PREEMPT Wed Dec 8 15:06:51 CET 2021 armv7l GNU/Linux
pi@raspberrypi:~/scrcpy $ lsmod
Module                  Size  Used by
mwifiex_sdio           32768  0
mwifiex               237568  1 mwifiex_sdio
tegra30_tsensor        16384  0
efivarfs               16384  0
pi@raspberrypi:~/scrcpy $ 
@rom1v
Copy link
Collaborator

rom1v commented Mar 16, 2022

Illegal instruction

This is a problem on the client side, it looks like a build problem.

Could you build with sanitizer enabled please?

meson d -Db_sanitize=address,undefined
ninja -Cd
./run d

(or run in gdb to know where this "illegal instruction" happens)

@fuch123
Copy link
Author

fuch123 commented Mar 16, 2022

Because I don't want to recompile the server, I compiled it with reference to common steps and option 2 on the website
However, an error occurred, as follows:

pi@raspberrypi:~ $ cd scrcpy/
pi@raspberrypi:~/scrcpy $ meson d -Db_sanitize=address,undefined -Dprebuilt_server=/home/pi/scrcpy/scrcpy-server
The Meson build system
Version: 0.56.2
Source dir: /home/pi/scrcpy
Build dir: /home/pi/scrcpy/d
Build type: native build
Project name: scrcpy
Project version: 1.23
C compiler for the host machine: cc (gcc 10.2.1 "cc (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110")
C linker for the host machine: cc ld.bfd 2.35.2
Host machine cpu family: arm
Host machine cpu: armv7l
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency libavformat found: YES 58.45.100
Run-time dependency libavcodec found: YES 58.91.100
Run-time dependency libavutil found: YES 56.51.100
Run-time dependency sdl2 found: YES 2.0.14
Run-time dependency libavdevice found: YES 58.10.100
Run-time dependency libusb-1.0 found: YES 1.0.24
Checking for function "strdup" : YES 
Checking for function "asprintf" : YES 
Checking for function "vasprintf" : YES 
Header <sys/socket.h> has symbol "SOCK_CLOEXEC" : YES 
Configuring config.h using configuration
Build targets in project: 14

Found ninja-1.10.1 at /usr/bin/ninja
pi@raspberrypi:~/scrcpy $ ninja -Cd
ninja: Entering directory `d'
[94/94] Linking target app/test_vector
pi@raspberrypi:~/scrcpy $ ./run d
==9417==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
pi@raspberrypi:~/scrcpy $ 

Sorry, I don't quite understand the method you gave. Can you be more detailed.
Thanks a lot.

@rom1v
Copy link
Collaborator

rom1v commented Mar 16, 2022

meson d -Db_sanitize=address,undefined -Dprebuilt_server=/home/pi/scrcpy/scrcpy-server

This is correct 👍

==9417==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.

You should not have this error: google/sanitizers#796

Maybe try building with clang instead (even if it should work out-of-the-box with gcc):

rm -rf d
export CC=clang
meson d -Db_sanitize=address,undefined -Dprebuilt_server=/home/pi/scrcpy/scrcpy-server
ninja -Cd
./run d

Otherwise, run it from gdb, you might get the backtrace:

export SCRCPY_SERVER_PATH=d/server/scrcpy-server
gdb d/app/scrcpy

Then, in gdb:

(gdb) r

And when it crashes with "illegal instruction":

(gdb) bt

It should print the backtrace. Paste it here.

@rom1v
Copy link
Collaborator

rom1v commented Mar 16, 2022

You could also try to remove undefined:

meson d -Db_sanitize=address -Dprebuilt_server=/home/pi/scrcpy/scrcpy-server

@fuch123
Copy link
Author

fuch123 commented Mar 17, 2022

Hi
I tried three methods you provided, but none of them succeeded.

(1) Common steps, with export CC = Lang, the results are as follows:

pi@raspberrypi:~/scrcpy $ export CC=clang
pi@raspberrypi:~/scrcpy $ meson d -Db_sanitize=address -Dprebuilt_server=/home/pi/scrcpy/scrcpy-server
The Meson build system
Version: 0.56.2
Source dir: /home/pi/scrcpy
Build dir: /home/pi/scrcpy/d
Build type: native build
Project name: scrcpy
Project version: 1.23
Using 'CC' from environment with value: 'clang'

meson.build:1:0: ERROR: Unknown compiler(s): [['clang']]
The follow exceptions were encountered:
Running "clang --version" gave "[Errno 2] No such file or directory: 'clang'"

A full log can be found at /home/pi/scrcpy/d/meson-logs/meson-log.txt
pi@raspberrypi:~/scrcpy $ 

(2) Common steps, without export CC = Lang, in gdb , the results are as follows:

pi@raspberrypi:~/scrcpy $ meson d -Db_sanitize=address -Dprebuilt_server=/home/pi/scrcpy/scrcpy-server
The Meson build system
Version: 0.56.2
Source dir: /home/pi/scrcpy
Build dir: /home/pi/scrcpy/d
Build type: native build
Project name: scrcpy
Project version: 1.23
C compiler for the host machine: cc (gcc 10.2.1 "cc (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110")
C linker for the host machine: cc ld.bfd 2.35.2
Host machine cpu family: arm
Host machine cpu: armv7l
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency libavformat found: YES 58.45.100
Run-time dependency libavcodec found: YES 58.91.100
Run-time dependency libavutil found: YES 56.51.100
Run-time dependency sdl2 found: YES 2.0.14
Run-time dependency libavdevice found: YES 58.10.100
Run-time dependency libusb-1.0 found: YES 1.0.24
Checking for function "strdup" : YES 
Checking for function "asprintf" : YES 
Checking for function "vasprintf" : YES 
Header <sys/socket.h> has symbol "SOCK_CLOEXEC" : YES 
Configuring config.h using configuration
Build targets in project: 14

Found ninja-1.10.1 at /usr/bin/ninja
pi@raspberrypi:~/scrcpy $ ninja -Cd
ninja: Entering directory `d'
[94/94] Linking target app/test_vector
pi@raspberrypi:~/scrcpy $ export SCRCPY_SERVER_PATH=d/server/scrcpy-server
pi@raspberrypi:~/scrcpy $ gdb -q d/app/scrcpy
Reading symbols from d/app/scrcpy...
(gdb) r
Starting program: /home/pi/scrcpy/d/app/scrcpy 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
==2478==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
[Inferior 1 (process 2478) exited with code 01]
(gdb) bt
No stack.
(gdb)  

(3) build scrcpy in Simple, and run it in GDB, the result is as follows:

pi@raspberrypi:~/scrcpy $ cd scrcpy
pi@raspberrypi:~/scrcpy $ sudo ninja -Cbuild-auto uninstall
pi@raspberrypi:~/scrcpy $ git pull
pi@raspberrypi:~/scrcpy $ ./install_release.sh
pi@raspberrypi:~/scrcpy $ gdb -q scrcpy
Reading symbols from scrcpy...
(No debugging symbols found in scrcpy)
(gdb) r
Starting program: /usr/local/bin/scrcpy 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
scrcpy 1.23 <https://github.com/Genymobile/scrcpy>
[New Thread 0xabdc9a80 (LWP 2977)]
[Detaching after fork from child process 2978]
[Detaching after fork from child process 2979]
[Detaching after fork from child process 2980]
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 2.8 MB/s (41123 bytes in 0.014s)
[Detaching after fork from child process 2982]
[Detaching after fork from child process 2983]
[New Thread 0xab3fea80 (LWP 2984)]
[server] INFO: Device: Xiaomi M2102J2SC (Android 12)
[Detaching after fork from child process 2986]
[New Thread 0xa3cb3a80 (LWP 3005)]
[New Thread 0xa32fea80 (LWP 3006)]
[New Thread 0xa28fea80 (LWP 3007)]
[New Thread 0xa1efea80 (LWP 3008)]
[New Thread 0xa14fea80 (LWP 3009)]
[New Thread 0xa0cfda80 (LWP 3010)]
[New Thread 0xa00fea80 (LWP 3011)]
[New Thread 0x9f8fda80 (LWP 3012)]
[New Thread 0x9efbba80 (LWP 3013)]
[New Thread 0x9e7baa80 (LWP 3014)]
[New Thread 0x9dfb9a80 (LWP 3015)]
[New Thread 0x9d7b8a80 (LWP 3016)]
[New Thread 0x9cfb7a80 (LWP 3017)]
[New Thread 0x9c7b6a80 (LWP 3018)]
INFO: Renderer: opengl
INFO: OpenGL version: 3.1 Mesa 20.3.5
INFO: Trilinear filtering enabled

Thread 1 "scrcpy" received signal SIGILL, Illegal instruction.
0xb5eee7e8 in avpriv_mpegaudio_decode_header () from /lib/arm-linux-gnueabihf/neon/vfp/libavcodec.so.58
(gdb) bt
#0  0xb5eee7e8 in avpriv_mpegaudio_decode_header () at /lib/arm-linux-gnueabihf/neon/vfp/libavcodec.so.58
#1  0xb6e59b34 in  () at /lib/arm-linux-gnueabihf/neon/vfp/libavformat.so.58
(gdb) 

Let me remind again that my Linux host is the raspbian Linux system of arm32, Is the problem still due to the hardware codec

I feel that test (3) can reflect the problem and help analyze it. How to solve it? Thanks a lot!

@fuch123
Copy link
Author

fuch123 commented Mar 25, 2022

Hello, moderator.

After that, I did several experiments and installed clang. The compilation was successful, but there was still an illegal instruction error when running. The situation is as follows:

pi@raspberrypi:~/scrcpy $ rm -rfv d

pi@raspberrypi:~/scrcpy $ export CC=clang

pi@raspberrypi:~/scrcpy $ meson d -Db_sanitize=address -Dprebuilt_server=/home/pi/scrcpy/scrcpy-server
The Meson build system
Version: 0.56.2
Source dir: /home/pi/scrcpy
Build dir: /home/pi/scrcpy/d
Build type: native build
Project name: scrcpy
Project version: 1.23
Using 'CC' from environment with value: 'clang'
C compiler for the host machine: clang (clang 11.0.1-2 "Raspbian clang version 11.0.1-2+rpi1")
C linker for the host machine: clang ld.bfd 2.35.2
Using 'CC' from environment with value: 'clang'
Host machine cpu family: arm
Host machine cpu: armv7l
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency libavformat found: YES 58.45.100
Run-time dependency libavcodec found: YES 58.91.100
Run-time dependency libavutil found: YES 56.51.100
Run-time dependency sdl2 found: YES 2.0.14
Run-time dependency libavdevice found: YES 58.10.100
Run-time dependency libusb-1.0 found: YES 1.0.24
Checking for function "strdup" : YES
Checking for function "asprintf" : YES
Checking for function "vasprintf" : YES
Header <sys/socket.h> has symbol "SOCK_CLOEXEC" : YES
Configuring config.h using configuration
Build targets in project: 14
meson.build:18: WARNING: Trying to use address sanitizer on Clang with b_lundef.
This will probably not work.
Try setting b_lundef to false instead.
Found ninja-1.10.1 at /usr/bin/ninja

pi@raspberrypi:~/scrcpy $ ninja -Cd
ninja: Entering directory `d'
[94/94] Linking target app/test_vector

pi@raspberrypi:~/scrcpy $ ./run d
scrcpy 1.23 https://github.com/Genymobile/scrcpy

  • daemon not running; starting now at tcp:5037
  • daemon started successfully
    DEBUG: ADB device found:
    DEBUG: --> (usb) 103a8504 device M2102J2SC
    DEBUG: Device serial: 103a8504
    DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
    d/server/scrcpy-server: 1 file pushed. 2.9 MB/s (41123 bytes in 0.013s)
    [server] INFO: Device: Xiaomi M2102J2SC (Android 12)
    [server] DEBUG: Using encoder: 'OMX.qcom.video.encoder.avc'
    DEBUG: Server disconnected
    DEBUG: Server terminated
    DEBUG: Server connected
    DEBUG: Starting controller thread
    DEBUG: Starting receiver thread
    DEBUG: Receiver stopped
    INFO: Renderer: opengl
    INFO: OpenGL version: 3.1 Mesa 20.3.5
    INFO: Trilinear filtering enabled
    DEBUG: Using SCRCPY_ICON_PATH: data/icon.png
    ERROR: Could not open image codec: data/icon.png
    WARN: Could not load icon
    INFO: Initial texture: 1080x2336
    DEBUG: Starting demuxer thread
    ./run: line 25: 2837 Illegal instruction SCRCPY_ICON_PATH="data/icon.png" SCRCPY_SERVER_PATH="$BUILDDIR/server/scrcpy-server" "$BUILDDIR/app/scrcpy" "$@"

pi@raspberrypi:~/scrcpy $ export SCRCPY_SERVER_PATH=d/server/scrcpy-server

pi@raspberrypi:~/scrcpy $ gdb -q d/app/scrcpy
Reading symbols from d/app/scrcpy...
(gdb) r
Starting program: /home/pi/scrcpy/d/app/scrcpy
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
scrcpy 1.23 https://github.com/Genymobile/scrcpy
[New Thread 0xa75fea40 (LWP 2908)]
[Detaching after fork from child process 2909]
[Detaching after fork from child process 2910]
DEBUG: ADB device found:
DEBUG: --> (usb) 103a8504 device M2102J2SC
DEBUG: Device serial: 103a8504
DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
[Detaching after fork from child process 2911]
d/server/scrcpy-server: 1 file pushed. 1.0 MB/s (41123 bytes in 0.038s)
[Detaching after fork from child process 2912]
[Detaching after fork from child process 2913]
[New Thread 0xa61fea40 (LWP 2914)]
[server] INFO: Device: Xiaomi M2102J2SC (Android 12)
[Detaching after fork from child process 2916]
[server] DEBUG: Using encoder: 'OMX.qcom.video.encoder.avc'
[New Thread 0x9d7fea40 (LWP 2917)]
[New Thread 0x9cffda40 (LWP 2918)]
[New Thread 0x9c7fca40 (LWP 2919)]
[New Thread 0x9bffba40 (LWP 2920)]
[New Thread 0x9b7faa40 (LWP 2921)]
[New Thread 0x9aff9a40 (LWP 2922)]
[New Thread 0x9a7f8a40 (LWP 2923)]
[New Thread 0x99ff7a40 (LWP 2924)]
[New Thread 0x996b5a40 (LWP 2925)]
[New Thread 0x98eb4a40 (LWP 2926)]
[New Thread 0x986b3a40 (LWP 2927)]
[New Thread 0x97eb2a40 (LWP 2928)]
DEBUG: Server connected
DEBUG: Starting controller thread
[New Thread 0x936fea40 (LWP 2929)]
DEBUG: Starting receiver thread
[New Thread 0x92efda40 (LWP 2930)]
INFO: Renderer: opengl
INFO: OpenGL version: 3.1 Mesa 20.3.5
INFO: Trilinear filtering enabled
DEBUG: Using icon: /usr/local/share/icons/hicolor/256x256/apps/scrcpy.png
ERROR: Could not open image codec: /usr/local/share/icons/hicolor/256x256/apps/scrcpy.png
WARN: Could not load icon
INFO: Initial texture: 1080x2336
DEBUG: Starting demuxer thread
[New Thread 0x8e0f6a40 (LWP 2931)]

Thread 18 "scrcpy-demuxer" received signal SIGILL, Illegal instruction.
[Switching to Thread 0x8e0f6a40 (LWP 2931)]
0xb5cbfe1c in ?? () from /lib/arm-linux-gnueabihf/neon/vfp/libavcodec.so.58
(gdb) bt
#0 0xb5cbfe1c in () at /lib/arm-linux-gnueabihf/neon/vfp/libavcodec.so.58
#1 0x1ffffffe in ()
(gdb)

The above is the specific test situation. Please help me to see if it can be solved. Thank you!

@rom1v
Copy link
Collaborator

rom1v commented Mar 25, 2022

0xb5cbfe1c in ?? () from /lib/arm-linux-gnueabihf/neon/vfp/libavcodec.so.58

Looks like an issue in your ffmpeg build (libavcodec).

@fuch123
Copy link
Author

fuch123 commented Mar 25, 2022

Is there any solution? Those library files are installed through apt.

Or guide me to compile those ffmpeg library files on my own machine.

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

No branches or pull requests

2 participants