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

Segmentation Fault while recording video ! #707

Closed
aiamuzz opened this issue Aug 8, 2019 · 41 comments
Closed

Segmentation Fault while recording video ! #707

aiamuzz opened this issue Aug 8, 2019 · 41 comments
Labels

Comments

@aiamuzz
Copy link

aiamuzz commented Aug 8, 2019

Hi,

Its a great android mirroring package you have going ...

My Nexus has some hardware issue with the screen ... the screen does not display the contents instead it shows a black/grey lit screen ... So i set out to see how i could access my nexus 5 device in this state from a PC so i can backup my stuff (messages(sms's), internal storage, etc ...) ... i came across you package i have built it using your instructions on my system running linux ... and my android screen is visible too ... My problem is that i have a pattern lock ... for the life of me i am not able to figure out how do i unlock the same from my PC ... or if that is even possible to do with your packae ... any / all help appreciated to help open my Nexus 5 via the PC and run backups for my stuff.

thanks.

@rom1v
Copy link
Collaborator

rom1v commented Aug 8, 2019

What does it do if you just draw the pattern with your mouse (left click hold)?

@aiamuzz
Copy link
Author

aiamuzz commented Aug 8, 2019

What does it do if you just draw the pattern with your mouse (left click hold)?

I am unable to drag the screen to reveal the pattern screen ... accidentally when i land the pattern lock screen ... then when i try to draw the pattern with the left click held down ... nothing seems to happen ... after a while the screen timesout ... and i am back to my struggle !!!

😢

@aiamuzz
Copy link
Author

aiamuzz commented Aug 9, 2019

@rom1v ... turns out the mouse cursor actions on the mobile screen is very very slow ... as a result it seems mostly unresponsive ... swiping the screen on wake is quite a challenge ...

If i have to give u an idea of how slow and unresponsive it is ...

The right click action on the phone window which supposedly wakes the phone(same as the physical power button action to wake) ... turns out it takes about 10-12 secs for the screen to show from a black screen(display off sleep state) to the lock screen

FYI ... i am using the command scrcpy -b1M -m600 to launch the phone instance on the PC ... is there any particular setting that will enable a fast and instant responsiveness with the mouse ?

PS : my laptop is loaded with 16GB of RAM with an i5 processor ... i don't think my machine is the reason for the sluggish(like how a sloth moves) response ... I am guessing it must be something that may have to do with the speed of communication between the system and the phone

thanks.

@rom1v
Copy link
Collaborator

rom1v commented Aug 9, 2019

turns out it takes about 10-12 secs for the screen to show from a black screen(display off sleep state) to the lock screen

Wow, that's unexpected, it should be instantaneous. Maybe your device itself is lagging.

What happens if you send the POWER event via:

adb shell input keyevent POWER

(both while scrcpy is running and not running)?

@aiamuzz
Copy link
Author

aiamuzz commented Aug 9, 2019

Wow, that's unexpected, it should be instantaneous. Maybe your device itself is lagging.

hmmmmm ... my device isn't lagging ... it is as responsive as a Google Nexus 5 with 2 Gb RAM is supposed to be ... unfortunately my device screen isn't consistent ... it doesn't wake or show anything ... its just a blackish-grey lit screen ...

What happens if you send the POWER event via:

adb shell input keyevent POWER

no difference ... the screen wakes up pretty slow even with the command (with scrcpy running)

(both while scrcpy is running and not running)?

unfortunately i can't test it with scrcpy not running as the screen is bust !!!

@rom1v
Copy link
Collaborator

rom1v commented Aug 9, 2019

Maybe the video is lagging (you press POWER, it wakes up immediately but you don't see it until the frames are received and decoded).

To determine if this is the case, record the video:

scrcpy -b1M -m600 -r file.mkv

Press power to switch off and switch on (it takes times in your scrcpy window). Then close the scrcpy window, and open file.mkv in a video player (like VLC), where you will see what happened in "real time" (the frame timestamps are generated on the device side for recording).

@aiamuzz
Copy link
Author

aiamuzz commented Aug 9, 2019

To determine if this is the case, record the video:

scrcpy -b1M -m600 -r file.mkv

I tried the above command ... the window showed for a split second and closed ... giving the following error ...

$ scrcpy -b1M -m600 -r scrcpy_lag_troubleshooting.mkv

INFO: scrcpy 1.10 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server.jar: 1 file pushed. 1.7 MB/s (22546 bytes in 0.012s)
INFO: Recording started to matroska file: scrcpy_lag_troubleshooting.mkv
INFO: Initial texture: 336x600
Segmentation fault (core dumped)

Maybe the video is lagging (you press POWER, it wakes up immediately but you don't see it until the frames are received and decoded).

Yeah ... even i feel the process(receive and decoded) communication between the devices(phone and laptop) is what is slow and sluggish ... takes away the whole experience of accessing your phone on your system ... 😭 ...

@rom1v
Copy link
Collaborator

rom1v commented Aug 9, 2019

INFO: Recording started to matroska file: scrcpy_lag_troubleshooting.mkv
INFO: Initial texture: 336x600
Segmentation fault (core dumped)

😱 This is a serious bug.

Does it also happen in mp4?

 scrcpy -b1M -m600 -r scrcpy_lag_troubleshooting.mp4

If it still crashes, could you test with v1.9 instead of v1.10, please (a lot of things have changed about parsing and recording)?

I cannot reproduce (also on a Nexus 5). What is your operating system / distribution on the computer?

I'm very interested in tracking down the cause. Could you compile and run with:

meson debug -Db_sanitize=address
ninja -Cdebug
./run debug -b1M -m600 -r scrcpy_lag_troubleshooting.mkv

Yeah ... even i feel the process(receive and decoded) communication between the devices(phone and laptop) is what is slow and sluggish ... takes away the whole experience of accessing your phone on your system ...

We need to determine where the lag come from. Typically, controlling the device and get a feedback should be near-instantaneous (few dozens of milliseconds).

@aiamuzz
Copy link
Author

aiamuzz commented Aug 9, 2019

This is a serious bug.

Does it also happen in mp4?

 scrcpy -b1M -m600 -r scrcpy_lag_troubleshooting.mp4

$ scrcpy -b1M -m600 -r scrcpy_lag_troubleshooting.mp4

INFO: scrcpy 1.10 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server.jar: 1 file pushed. 2.0 MB/s (22546 bytes in 0.011s)
INFO: Recording started to mp4 file: scrcpy_lag_troubleshooting.mp4
INFO: Initial texture: 336x600
Segmentation fault (core dumped)

I cannot reproduce (also on a Nexus 5). What is your operating system / distribution on the computer?

I am on Linux Deepin latest version ...
an additional observation, if its any good ... the 'windows effect' a setting that is essential to run kwin Windows Manager gets disabled the moment the scrcpy window opens with the device !

If it still crashes, could you test with v1.9 instead of v1.10, please (a lot of things have changed about parsing and recording)?

rebuilt and installed with v1.9 following the below directions ...

meson x --buildtype release --strip -Db_lto=true     -Dprebuilt_server=/home/muz/Downloads/linuxPackagesBuildnInstall/scrcpy/scrcpy-server-v1.9.jar
cd x
ninja
sudo ninja install

I'm very interested in tracking down the cause. Could you compile and run with:

meson debug -Db_sanitize=address
ninja -Cdebug
./run debug -b1M -m600 -r scrcpy_lag_troubleshooting.mkv

I am glad to help you grab whatever info from my machine facing this bug ... 😄

$ meson debug -Db_sanitize=address

The Meson build system
Version: 0.47.2
Source dir: /home/muz/Downloads/linuxPackagesBuildnInstall/scrcpy/scrcpy-1.9
Build dir: /home/muz/Downloads/linuxPackagesBuildnInstall/scrcpy/scrcpy-1.9/debug
Build type: native build
Project name: scrcpy
Project version: 1.9
Native C compiler: cc (gcc 6.3.0 "cc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (0.29)
Native dependency libavformat found: YES 57.56.101
Native dependency libavcodec found: YES 57.64.101
Native dependency libavutil found: YES 55.34.101
Native dependency sdl2 found: YES 2.0.5
Configuring config.h using configuration
Program ./scripts/build-wrapper.sh found: YES (/home/muz/Downloads/linuxPackagesBuildnInstall/scrcpy/scrcpy-1.9/server/./scripts/build-wrapper.sh)
DEPRECATION: build_always is deprecated. Combine build_by_default and build_always_stale instead.
Build targets in project: 7
Found ninja-1.7.2 at /usr/bin/ninja
Fri Aug 09 06:31 PM - muz@ALHAMxxxxxxx33: ~/Downloads/linuxPackagesBuildnInstall/scrcpy/scrcpy-1.9  
$ ninja -Cdebug
ninja: Entering directory `debug'
[36/37] Linking target app/scrcpy.

the command hasn't terminated yet ...

I opened another terminal tab and tried running the 3rd command ...

Fri Aug 09 06:32 PM - muz@ALHAMxxxxxxxx33: ~/Downloads/linuxPackagesBuildnInstall/scrcpy/scrcpy-1.9  
$ ./run debug -b1M -m600 -r scrcpy_lag_troubleshooting.mkv
DEBUG: Using SCRCPY_SERVER_PATH: debug/server/scrcpy-server.jar
adb: error: cannot stat 'debug/server/scrcpy-server.jar': No such file or directory
ERROR: "adb push" returned with value 1

please check if i am running the above commands from inside the right directories(folders) ...

@rom1v
Copy link
Collaborator

rom1v commented Aug 9, 2019

the command hasn't terminated yet ...

In fact, it is building the server (the first time, gradle download the whole internet before it can compile), and meson doesn't print its output. I just changed that in 20b3f10 (but you use a version < 0.48 anyway).

adb: error: cannot stat 'debug/server/scrcpy-server.jar': No such file or directory

The reason is that the build of the server is not complete. You must wait for your previous command to complete. Alternatively, you could use the prebuilt server.

@aiamuzz
Copy link
Author

aiamuzz commented Aug 9, 2019

UPDATE :

sorry the command did execute completely ... i took that command to be something that runs in the background so it can collect debug information ...

anyways the following is the output of the command ...

$ ninja -Cdebug

ninja: Entering directory `debug'
[37/37] Generating scrcpy-server with a custom command.
Downloading https://services.gradle.org/distributions/gradle-4.10.1-all.zip
..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Unzipping /home/muz/.gradle/wrapper/dists/gradle-4.10.1-all/455itskqi2qtf0v2sja68alqd/gradle-4.10.1-all.zip to /home/muz/.gradle/wrapper/dists/gradle-4.10.1-all/455itskqi2qtf0v2sja68alqd
Set executable permissions for: /home/muz/.gradle/wrapper/dists/gradle-4.10.1-all/455itskqi2qtf0v2sja68alqd/gradle-4.10.1/bin/gradle

Welcome to Gradle 4.10.1!

Here are the highlights of this release:
 - Incremental Java compilation by default
 - Periodic Gradle caches cleanup
 - Gradle Kotlin DSL 1.0-RC6
 - Nested included builds
 - SNAPSHOT plugin versions in the `plugins {}` block

For more details see https://docs.gradle.org/4.10.1/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :server
Observed package id 'add-ons;addon-google_apis-google-19' in inconsistent location '/media/muz/LinuxZandroid/AndroidSDKDeepin/sdk/add-ons/addon-google_apis-google-19-1' (Expected '/media/muz/LinuxZandroid/AndroidSDKDeepin/sdk/add-ons/addon-google_apis-google-19')
Observed package id 'system-images;android-14;default;armeabi-v7a' in inconsistent location '/media/muz/LinuxZandroid/AndroidSDKDeepin/sdk/system-images/android-14/armeabi-v7a' (Expected '/media/muz/LinuxZandroid/AndroidSDKDeepin/sdk/system-images/android-14/default/armeabi-v7a')
Observed package id 'system-images;android-15;default;mips' in inconsistent location '/media/muz/LinuxZandroid/AndroidSDKDeepin/sdk/system-images/android-15/mips' (Expected '/media/muz/LinuxZandroid/AndroidSDKDeepin/sdk/system-images/android-15/default/mips')
Observed package id 'system-images;android-16;default;mips' in inconsistent location '/media/muz/LinuxZandroid/AndroidSDKDeepin/sdk/system-images/android-16/mips' (Expected '/media/muz/LinuxZandroid/AndroidSDKDeepin/sdk/system-images/android-16/default/mips')
Observed package id 'system-images;android-17;default;mips' in inconsistent location '/media/muz/LinuxZandroid/AndroidSDKDeepin/sdk/system-images/android-17/mips' (Expected '/media/muz/LinuxZandroid/AndroidSDKDeepin/sdk/system-images/android-17/default/mips')

> Task :server:preBuild UP-TO-DATE
> Task :server:preDebugBuild
> Task :server:compileDebugAidl
> Task :server:compileDebugRenderscript
> Task :server:checkDebugManifest
> Task :server:generateDebugBuildConfig
> Task :server:prepareLintJar
> Task :server:generateDebugSources
> Task :server:javaPreCompileDebug
> Task :server:mainApkListPersistenceDebug
> Task :server:generateDebugResValues
> Task :server:generateDebugResources
> Task :server:mergeDebugResources
> Task :server:createDebugCompatibleScreenManifests
> Task :server:processDebugManifest
> Task :server:processDebugResources
> Task :server:compileDebugJavaWithJavac
> Task :server:compileDebugNdk NO-SOURCE
> Task :server:compileDebugSources
> Task :server:mergeDebugShaders
> Task :server:compileDebugShaders
> Task :server:generateDebugAssets
> Task :server:mergeDebugAssets
> Task :server:mergeExtDexDebug
> Task :server:mergeLibDexDebug
> Task :server:transformClassesWithDexBuilderForDebug
> Task :server:mergeProjectDexDebug
> Task :server:validateSigningDebug
> Task :server:signingConfigWriterDebug
> Task :server:mergeDebugJniLibFolders
> Task :server:transformNativeLibsWithMergeJniLibsForDebug
> Task :server:processDebugJavaRes NO-SOURCE
> Task :server:transformResourcesWithMergeJavaResForDebug
> Task :server:packageDebug
> Task :server:assembleDebug

BUILD SUCCESSFUL in 3m 17s
27 actionable tasks: 27 executed

after that i tried running this command and it runs successfully ...

$ ./run debug -b1M -m600 -r scrcpy_lag_troubleshooting.mkv

DEBUG: Using SCRCPY_SERVER_PATH: debug/server/scrcpy-server.jar
debug/server/scrcpy-server.jar: 1 file pushed. 2.2 MB/s (31431 bytes in 0.013s)
DEBUG: Starting stream thread
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
INFO: OpenGL shaders: ENABLED
INFO: Created renderer: opengl
INFO: Initial texture: 336x600
INFO: Recording started to matroska file: scrcpy_lag_troubleshooting.mkv
DEBUG: User requested to quit
DEBUG: quit...
DEBUG: Receiver stopped
INFO: Recording complete to matroska file: scrcpy_lag_troubleshooting.mkv
DEBUG: Server terminated

=================================================================
==6153==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 152 byte(s) in 2 object(s) allocated from:
    #0 0x7ff6442ad090 in realloc (/lib/x86_64-linux-gnu/libasan.so.3+0xc2090)
    #1 0x7ff63b51d6bc  (/lib/x86_64-linux-gnu/libX11.so.6+0x556bc)

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7ff6442aced0 in calloc (/lib/x86_64-linux-gnu/libasan.so.3+0xc1ed0)
    #1 0x7ff63b55aa90 in XkbGetMap (/lib/x86_64-linux-gnu/libX11.so.6+0x92a90)

Direct leak of 1 byte(s) in 1 object(s) allocated from:
    #0 0x7ff6442acd28 in malloc (/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
    #1 0x7ff63b5270a4 in _XlcDefaultMapModifiers (/lib/x86_64-linux-gnu/libX11.so.6+0x5f0a4)

Indirect leak of 1520 byte(s) in 19 object(s) allocated from:
    #0 0x7ff6442aced0 in calloc (/lib/x86_64-linux-gnu/libasan.so.3+0xc1ed0)
    #1 0x7ff63b51d68e  (/lib/x86_64-linux-gnu/libX11.so.6+0x5568e)

Indirect leak of 128 byte(s) in 16 object(s) allocated from:
    #0 0x7ff6442acd28 in malloc (/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
    #1 0x7ff63b51e10d  (/lib/x86_64-linux-gnu/libX11.so.6+0x5610d)

Indirect leak of 80 byte(s) in 3 object(s) allocated from:
    #0 0x7ff6442ad090 in realloc (/lib/x86_64-linux-gnu/libasan.so.3+0xc2090)
    #1 0x7ff63b51e050  (/lib/x86_64-linux-gnu/libX11.so.6+0x56050)

SUMMARY: AddressSanitizer: 1953 byte(s) leaked in 42 allocation(s).

I have a mkv file captured ... how do i share it with you ?
i guess i can't post it on this thread ...

anyways there is nothing in the video except that the screen is showing ... after a while it goes to sleep and i press right click and the screen lights up after the 10-12 sec delay and it shows up until i closed it ...

Note : all the while when the screen was visible ... i have been left clicking and dragging the screen lock so i could enter the phone ... even after the screen woke up after it went to sleep ... obviously none of those attempts show up on the captured video.

@rom1v
Copy link
Collaborator

rom1v commented Aug 9, 2019

after that i tried running this command and it runs successfully ...

Arf, I hoped it crashed the same way with the stack trace. If you could make it crash like before, I'm interested :) Is your non-debug binary still crashing if you retry, or was it just a one-time crash?

I have a mkv file captured ... how do i share it with you ?

I don't need it, it was just to know if you observed the very same delay on the recorded an in live. So it seems this is really a control problem.

Since it also happen with adb shell input keyevent POWER, it's not related to scrcpy. Maybe you could get error traces in adb logcat which explains why it is so slow. (Maybe it is related to your screen being broken.)

@aiamuzz
Copy link
Author

aiamuzz commented Aug 9, 2019

Based on your directions i tested 1.9 ... as mentioned above ... when i tried running the normal command hoping to run the installed 1.9 version ... i got the following ...

$ scrcpy -b1M -m600

adb: error: cannot stat '/usr/local/bin/scrcpy-server.jar': No such file or directory
ERROR: "adb push" returned with value 1

I rebuilt the version 1.10 once again ... and the crash still exist on 1.10 ...

$ scrcpy -b1M -m600 -r scrcpy_lag_troubleshooting.mkv

INFO: scrcpy 1.10 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server.jar: 1 file pushed. 2.3 MB/s (22546 bytes in 0.009s)
INFO: Recording started to matroska file: scrcpy_lag_troubleshooting.mkv
INFO: Initial texture: 336x600
Segmentation fault (core dumped)

Arf, I hoped it crashed the same way with the stack trace. If you could make it crash like before, I'm interested :) Is your non-debug binary still crashing if you retry, or was it just a one-time crash?

do you mean you wanted me to crash it the same way on 1.9 ?

@rom1v
Copy link
Collaborator

rom1v commented Aug 9, 2019

Based on your directions i tested 1.9 ... as mentioned above ... when i tried running the normal command hoping to run the installed 1.9 version ... i got the following ...

adb: error: cannot stat '/usr/local/bin/scrcpy-server.jar': No such file or directory
ERROR: "adb push" returned with value 1

OK, do not compile from tag v1.9, but few commits later (due to #583): 53310a9.

I rebuilt the version 1.10 once again ... and the crash still exist on 1.10 ...

That's great! But can you reproduce it with ASAN enabled (-Db_sanitize=address, #707 (comment))

do you mean you wanted me to crash it the same way on 1.9 ?

No, I wanted to get the crash with the stacktrace from ASAN so that we can find the cause 😉

But testing if v1.9 crash could also "help".

@aiamuzz
Copy link
Author

aiamuzz commented Aug 9, 2019

That's great! But can you reproduce it with ASAN enabled (-Db_sanitize=address, #707 (comment))

ok ... here you go ... is this what you were hoping to find ?

$ ./run debug -b1M -m600 -r scrcpy_lag_troubleshooting.mkv

INFO: scrcpy 1.10 <https://github.com/Genymobile/scrcpy>
DEBUG: Using SCRCPY_SERVER_PATH: debug/server/scrcpy-server.jar
debug/server/scrcpy-server.jar: 1 file pushed. 8.1 MB/s (31420 bytes in 0.004s)
DEBUG: Starting stream thread
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
INFO: Recording started to matroska file: scrcpy_lag_troubleshooting.mkv
DEBUG: Starting recorder thread
INFO: OpenGL shaders: ENABLED
INFO: Created renderer: opengl
INFO: Initial texture: 336x600
ASAN:DEADLYSIGNAL
=================================================================
==6471==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f5ef697c747 bp 0x7f5ed855d970 sp 0x7f5ed855d0e0 T5)
    #0 0x7f5ef697c746  (/lib/x86_64-linux-gnu/libasan.so.3+0x23746)
    #1 0x7f5ef6a1a9ec in free (/lib/x86_64-linux-gnu/libasan.so.3+0xc19ec)
    #2 0x7f5ef50cd448 in av_packet_free_side_data (/lib/x86_64-linux-gnu/libavcodec.so.57+0x184448)
    #3 0x7f5ef50cddbc in av_packet_unref (/lib/x86_64-linux-gnu/libavcodec.so.57+0x184dbc)
    #4 0x55de07a3eabd in record_packet_delete ../app/src/recorder.c:45
    #5 0x55de07a40212 in run_recorder ../app/src/recorder.c:269
    #6 0x7f5ef4a29eab  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0x7feab)
    #7 0x7f5ef4a79438  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0xcf438)
    #8 0x7f5ef3fe94a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
    #9 0x7f5ef46f3d0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libasan.so.3+0x23746) 
Thread T5 (recorder) created by T2 (stream) here:
    #0 0x7f5ef6989f59 in __interceptor_pthread_create (/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
    #1 0x7f5ef4a794a2  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0xcf4a2)

Thread T2 (stream) created by T0 here:
    #0 0x7f5ef6989f59 in __interceptor_pthread_create (/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
    #1 0x7f5ef4a794a2  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0xcf4a2)

==6471==ABORTING
[server] DEBUG: Controller stopped

@aiamuzz
Copy link
Author

aiamuzz commented Aug 9, 2019

I am on Linux Deepin latest version ...
an additional observation, if its any good ... the 'windows effect' a setting that is essential to run kwin Windows Manager gets disabled the moment the scrcpy window opens with the device !

what about the 'Windows Effect' getting disturbed when scrcpy is running ?
Is this a conflict of your package with regard to my environment ? Can you fix it so that this doesn't happen ?

@rom1v
Copy link
Collaborator

rom1v commented Aug 9, 2019

ok ... here you go ... is this what you were hoping to find ?

Exactly, thank you 👍 I will investigate later.

In addition, could you:

  • do the same test with v1.9 (commit 53310a9)
  • try to record to mp4 instead of mkv
  • copy the result of scrcpy -v to get the versions of the dependencies

Thank you.

what about the 'Windows Effect' getting disturbed when scrcpy is running ?

https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#kwin-compositor-crashes
#114 (comment)

@aiamuzz
Copy link
Author

aiamuzz commented Aug 9, 2019

ok ... here you go ... is this what you were hoping to find ?

Exactly, thank you I will investigate later.

In addition, could you:

  • do the same test with v1.9 (commit 53310a9)
  • try to record to mp4 instead of mkv
  • copy the result of scrcpy -v to get the versions of the dependencies

Thank you.

what about the 'Windows Effect' getting disturbed when scrcpy is running ?

https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#kwin-compositor-crashes
#114 (comment)

ok ... do i have to uninstall the 1.10 version and install 1.9 from scratch ?

@rom1v
Copy link
Collaborator

rom1v commented Aug 9, 2019

No, just:

git checkout 53310a925a495f61d42dd90faa0a0748074d63c5
ninja -Cdebug
./run debug -b1M -m600 -r file.mkv

@rom1v rom1v closed this as completed Aug 9, 2019
@rom1v rom1v reopened this Aug 9, 2019
@aiamuzz
Copy link
Author

aiamuzz commented Aug 10, 2019

No, just:

git checkout 53310a925a495f61d42dd90faa0a0748074d63c5
ninja -Cdebug
./run debug -b1M -m600 -r file.mkv

@rom1v ... i am not a pro at this ... these are the following steps i followed before i tried the above commands

git clone https://github.com/Genymobile/scrcpy
cd scrcpy/
meson x --buildtype release --strip -Db_lto=true
cd x
ninja

then i tried the following commands you wanted me to run ...

git checkout 53310a925a495f61d42dd90faa0a0748074d63c5
Output :
HEAD is now at 53310a9... Disable portable build by default

I tried running the following command both in the scrcpy folder as well as from inside the x folder
ninja -Cdebug
Output :

ninja: Entering directory `debug'
ninja: fatal: chdir to 'debug' - No such file or directory

with the above failing ... i guess the following command will give an error ...

./run debug -b1M -m600 -r file.mkv
Output :
bash: ./run: No such file or directory

@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2019

You can always use the same source folder without recloning with git clone.

From there, you can create several independant build directories, with different settings:

  • meson x will create a builddir x
  • meson debug will create a builddir debug
  • meson anything_you_want will create a builddir anything_you_want

And you can build the app using the builddir you configured:

  • ninja -Cx
  • ninja -Cdebug
  • ninja -Canything_you_want

To test in debug with ASAN, you can just reuse the debug builddiryou configured with-Db_sanitize=true`, for any scrcpy version.

Once a version is build, you can run it directly in your builddir without installing with sudo ninja -Cdebug install, just use ./run debug (or ./run x or ./run anything_you_want) with the args you want to pass to scrcpy.

So from scratch, to build v1.9:

git clone https://github.com/Genymobile/scrcpy
git checkout 53310a925a495f61d42dd90faa0a0748074d63c5
meson debug -Db_sanitize=address
ninja -Cdebug
./run debug -b1M -m600 -r file.mkv

@aiamuzz
Copy link
Author

aiamuzz commented Aug 10, 2019

So from scratch, to build v1.9:

git clone https://github.com/Genymobile/scrcpy
git checkout 53310a925a495f61d42dd90faa0a0748074d63c5
meson debug -Db_sanitize=true
ninja -Cdebug
./run debug -b1M -m600 -r file.mkv

@rom1v ... thanks for explaining the build process ...

$ ninja -Cdebug

```ninja: Entering directory `debug'
ninja: error: loading 'build.ninja': No such file or directory


getting the following error at this command ...

@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2019

Did your meson command work without errors?

@aiamuzz
Copy link
Author

aiamuzz commented Aug 10, 2019

Did your meson command work without errors?

I might have stumbled on another bug ...

git checkout 53310a925a495f61d42dd90faa0a0748074d63c5 : Success

$ meson debug -Db_sanitize=true

The Meson build system
Version: 0.47.2
Source dir: /media/muz/srcRepo/github/testingTroubleshooting/scrcpy
Build dir: /media/muz/srcRepo/github/testingTroubleshooting/scrcpy/debug
Build type: native build
Project name: scrcpy
Project version: 1.9
Native C compiler: cc (gcc 6.3.0 "cc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516")

meson.build:1:0: ERROR:  Value "true" for combo option "b_sanitize" is not one of the choices. Possible choices are: "none", "address", "thread", "undefined", "memory", "address,undefined".

A full log can be found at /media/muz/srcRepo/github/testingTroubleshooting/scrcpy/debug/meson-logs/meson-log.txt

i can see only these 2 folders ...
image

shouldn't all the additional folders that created when we run meson debug be created even with the sanitize option ?

i ran meson debug and now i see the rest of the file and folders being created ...
image

would have been nice if the command $ meson debug -Db_sanitize=true created the folders the command meson debug created ?

I tested 1.9 for the same crash ... turns out the command ./run debug -b1M -m600 -r file.mkv runs as intended without crashing ... seems the problem is only with 1.10 ...

@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2019

Sorry, it's -Db_sanitize=address.

@aiamuzz
Copy link
Author

aiamuzz commented Aug 10, 2019

So from scratch, to build v1.9:

git clone https://github.com/Genymobile/scrcpy
git checkout 53310a925a495f61d42dd90faa0a0748074d63c5
meson debug -Db_sanitize=address
ninja -Cdebug
./run debug -b1M -m600 -r file.mkv

@rom1v ... i was wondering the hash code or whatever code that is used here points to the Version 1.9 branch ?
git checkout 53310a925a495f61d42dd90faa0a0748074d63c5

How do we locate this code for each release ... can i view it with a command or find it on the github website ?

@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2019

This hashcode is few commits after v1.9, to fix a build issue (see #583). Otherwise, you could just git checkout v1.10 by the tag name.

You can get a graph:

git log --graph --oneline --decorate master

@aiamuzz
Copy link
Author

aiamuzz commented Aug 10, 2019

This hashcode is few commits after v1.9, to fix a build issue (see #583). Otherwise, you could just git checkout v1.10 by the tag name.

You can get a graph:

git log --graph --oneline --decorate master

oh ... ok so basically we could compile to that particular point on any commits ?

image

so is this the place where you grab the hashcode ?

thanks for the information ... didn't know one could checkout at that point and compile a package ... exactly after a particular commit ... git never ceases to amaze me !!!

@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2019

so is this the place where you grab the hashcode ?

GitHub displays the hash, but typically you get it from git commands.

git never ceases to amaze me !!!

If you are interested in git, I would recommend to read the 3 first chapters of git-scm.

I tested 1.9 for the same crash ... turns out the command ./run debug -b1M -m600 -r file.mkv runs as intended without crashing ... seems the problem is only with 1.10 ...

Thank you, this is helpful.

If you could git bisect to find the culprit, that would be awesome.

If you don't know how to do, could you just test recording to mkv for these specific commits (likely to introduce the issue):

Thank you for your help.

@aiamuzz
Copy link
Author

aiamuzz commented Aug 11, 2019

GitHub displays the hash, but typically you get it from git commands.

can you show me how you get the hash through commandline ?

If you are interested in git, I would recommend to read the 3 first chapters of git-scm.

great ... thank you for the resource ...

Thank you, this is helpful.

you are welcome.

If you could git bisect to find the culprit, that would be awesome.

If you don't know how to do, could you just test recording to mkv for these specific commits (likely to introduce the issue):

Thank you for your help.

ok ... it might be a while until i pick up git ... i'll test the commits you've pointed for this particular issue ...

@aiamuzz aiamuzz changed the title How to unlock device from the PC which has a pattern lock ? Segmentation Fault while recording video ! Aug 11, 2019
@aiamuzz
Copy link
Author

aiamuzz commented Aug 11, 2019

If you could git bisect to find the culprit, that would be awesome.

If you don't know how to do, could you just test recording to mkv for these specific commits (likely to introduce the issue):

Thank you for your help.

@rom1v ... tested the following commit hashes manually ... please find the test results below ...

Procedure i followed ...

git checkout 63af7fbafe3740b17b5495a8230298eff9d45581
meson 63af7fb -Db_sanitize=address
ninja -C63af7fb
./run 63af7fb -b1M -m600 -r video-63af7fb.mkv
git checkout 35d9185f6c3dc1c34ea7d46859ee89827e2fe74a
meson 35d9185 -Db_sanitize=address
ninja -C35d9185
./run 35d9185 -b1M -m600 -r video-35d9185.mkv
git checkout 5e4ccfd83298d3fb2e1c638b6235b811d034afdd
meson 5e4ccfd -Db_sanitize=address
ninja -C5e4ccfd
./run 5e4ccfd -b1M -m600 -r video-5e4ccfd.mkv
  1. 63af7fb - No Issues

  2. 35d9185

$ ./run 35d9185 -b1M -m600 -r video-35d9185.mkv
DEBUG: Using SCRCPY_SERVER_PATH: 35d9185/server/scrcpy-server.jar
35d9185/server/scrcpy-server.jar: 1 file pushed. 3.1 MB/s (56231 bytes in 0.017s)
DEBUG: Starting stream thread
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
INFO: Recording started to matroska file: video-35d9185.mkv
DEBUG: Starting recorder thread
INFO: OpenGL shaders: ENABLED
INFO: Created renderer: opengl
INFO: Initial texture: 376x600
ASAN:DEADLYSIGNAL
=================================================================
==4851==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f00fac08747 bp 0x7f00dc8329e0 sp 0x7f00dc832150 T5)
    #0 0x7f00fac08746  (/lib/x86_64-linux-gnu/libasan.so.3+0x23746)
    #1 0x7f00faca69ec in free (/lib/x86_64-linux-gnu/libasan.so.3+0xc19ec)
    #2 0x7f00f9359448 in av_packet_free_side_data (/lib/x86_64-linux-gnu/libavcodec.so.57+0x184448)
    #3 0x7f00f9359dbc in av_packet_unref (/lib/x86_64-linux-gnu/libavcodec.so.57+0x184dbc)
    #4 0x557595a54a90 in record_packet_delete ../app/src/recorder.c:46
    #5 0x557595a56088 in run_recorder ../app/src/recorder.c:312
    #6 0x7f00f8cb5eab  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0x7feab)
    #7 0x7f00f8d05438  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0xcf438)
    #8 0x7f00f82754a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
    #9 0x7f00f897fd0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libasan.so.3+0x23746) 
Thread T5 (recorder) created by T2 (stream) here:
    #0 0x7f00fac15f59 in __interceptor_pthread_create (/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
    #1 0x7f00f8d054a2  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0xcf4a2)

Thread T2 (stream) created by T0 here:
    #0 0x7f00fac15f59 in __interceptor_pthread_create (/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
    #1 0x7f00f8d054a2  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0xcf4a2)

==4851==ABORTING
Sun Aug 11 02:05 PM - muz@ALHAMDULILLAH33: /media/muz/srcRepo/github/testingTroubleshooting/scrcpy  
$ [server] DEBUG: Screen streaming stopped
[server] ERROR: Exception on thread Thread[Thread-1,5,main]
java.lang.AssertionError: java.lang.reflect.InvocationTargetException
	at com.genymobile.scrcpy.wrappers.InputManager.injectInputEvent(InputManager.java:31)
	at com.genymobile.scrcpy.Device.injectInputEvent(Device.java:124)
	at com.genymobile.scrcpy.Controller.injectEvent(Controller.java:194)
	at com.genymobile.scrcpy.Controller.injectKeyEvent(Controller.java:185)
	at com.genymobile.scrcpy.Controller.injectKeycode(Controller.java:190)
	at com.genymobile.scrcpy.Controller.control(Controller.java:60)
	at com.genymobile.scrcpy.Server$1.run(Server.java:45)
	at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.reflect.InvocationTargetException
	at java.lang.reflect.Method.invoke(Native Method)
	at com.genymobile.scrcpy.wrappers.InputManager.injectInputEvent(InputManager.java:29)
	... 7 more
Caused by: java.lang.RuntimeException: Bad file descriptor
	at android.os.BinderProxy.transactNative(Native Method)
	at android.os.BinderProxy.transact(Binder.java:615)
	at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:536)
	... 9 more
  1. 5e4ccfd -
$ ./run 5e4ccfd -b1M -m600 -r video-5e4ccfd.mkv
INFO: scrcpy 1.9 <https://github.com/Genymobile/scrcpy>
DEBUG: Using SCRCPY_SERVER_PATH: 5e4ccfd/server/scrcpy-server.jar
5e4ccfd/server/scrcpy-server.jar: 1 file pushed. 2.6 MB/s (56231 bytes in 0.021s)
DEBUG: Starting stream thread
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
INFO: Recording started to matroska file: video-5e4ccfd.mkv
DEBUG: Starting recorder thread
INFO: OpenGL shaders: ENABLED
INFO: Created renderer: opengl
INFO: Initial texture: 376x600
ASAN:DEADLYSIGNAL
=================================================================
==5557==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7faab3cb1747 bp 0x7faa9585d970 sp 0x7faa9585d0e0 T5)
    #0 0x7faab3cb1746  (/lib/x86_64-linux-gnu/libasan.so.3+0x23746)
    #1 0x7faab3d4f9ec in free (/lib/x86_64-linux-gnu/libasan.so.3+0xc19ec)
    #2 0x7faab2402448 in av_packet_free_side_data (/lib/x86_64-linux-gnu/libavcodec.so.57+0x184448)
    #3 0x7faab2402dbc in av_packet_unref (/lib/x86_64-linux-gnu/libavcodec.so.57+0x184dbc)
    #4 0x55f2c8407b85 in record_packet_delete ../app/src/recorder.c:45
    #5 0x55f2c84092a5 in run_recorder ../app/src/recorder.c:269
    #6 0x7faab1d5eeab  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0x7feab)
    #7 0x7faab1dae438  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0xcf438)
    #8 0x7faab131e4a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
    #9 0x7faab1a28d0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libasan.so.3+0x23746) 
Thread T5 (recorder) created by T2 (stream) here:
    #0 0x7faab3cbef59 in __interceptor_pthread_create (/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
    #1 0x7faab1dae4a2  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0xcf4a2)

Thread T2 (stream) created by T0 here:
    #0 0x7faab3cbef59 in __interceptor_pthread_create (/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
    #1 0x7faab1dae4a2  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0xcf4a2)

==5557==ABORTING
[server] DEBUG: Controller stoppedSun Aug 11 02:09 PM - muz@ALHAMDULILLAH33: /media/muz/srcRepo/github/testingTroubleshooting/scrcpy  
$ 
[server] DEBUG: Screen streaming stopped
^C

@GBwuka
Copy link

GBwuka commented Aug 13, 2019

in centos snap,I can't find other version of scrcpy to install , can release v1.9 version of scrcpy on snap please? i need to use scrcpy recently, thank you very much!
image

rom1v added a commit that referenced this issue Aug 13, 2019
The AVPacket fields side_data and side_data_elems were not initialized
by av_packet_ref() in old FFmpeg versions (prior to [1]).

As a consequence, on av_packet_unref(), side_data was freed, causing a
segfault.

Fixes <#707>

[1]: <http://git.videolan.org/gitweb.cgi/ffmpeg.git/?p=ffmpeg.git;a=commitdiff;h=3b4026e15110547892d5d770b6b43c9e34df458f>
rom1v added a commit that referenced this issue Aug 13, 2019
The AVPacket fields side_data and side_data_elems were not initialized
by av_packet_ref() in old FFmpeg versions (prior to [1]).

As a consequence, on av_packet_unref(), side_data was freed, causing a
segfault.

Fixes <#707>

[1]: <http://git.videolan.org/gitweb.cgi/ffmpeg.git/?p=ffmpeg.git;a=commitdiff;h=3b4026e15110547892d5d770b6b43c9e34df458f>
@rom1v
Copy link
Collaborator

rom1v commented Aug 13, 2019

I just investigated from the stack traces you provided (without being able to reproduce). I found a possible explanation: before this commit in FFmpeg (libavcodec < 58.12.100), the AVPacket fields side_data and side_data_elems were not initialized on av_packet_ref(). Since scrcpy did not initialize them either (since in theory it is not necessary), it crashed on av_packet_unref() when trying to free side_data (which contains garbage). This also explains why people reporting this issue use an old FFmpeg, while it works well for others.

Please test with this fix: a9c8fa3

git fetch
git checkout fix707
# then build as usual

Thank you.

@aiamuzz
Copy link
Author

aiamuzz commented Aug 13, 2019

a9c8fa3

@rom1v ... tested ... working ... i guess ur assumption of the possible cause of this bug was bang on !!!

Let me know if you want me to test any other commits.
😄

@rom1v
Copy link
Collaborator

rom1v commented Aug 13, 2019

tested ... working ...

Thank you. 👍 I merge it.

@rom1v rom1v closed this as completed Aug 13, 2019
@rom1v
Copy link
Collaborator

rom1v commented Aug 13, 2019

in centos snap,I can't find other version of scrcpy to install , can release v1.9 version of scrcpy on snap please? i need to use scrcpy recently, thank you very much!

I guess you can only install the last packaged version from snap. cc @sisco311

Anyway, if your FFmpeg version is recent enough, this segfault should not occur.

@aiamuzz
Copy link
Author

aiamuzz commented Aug 13, 2019

in centos snap,I can't find other version of scrcpy to install , can release v1.9 version of scrcpy on snap please? i need to use scrcpy recently, thank you very much!

I guess you can only install the last packaged version from snap. cc @sisco311

Anyway, if your FFmpeg version is recent enough, this segfault should not occur.

I was wondering if you'd package your app as a flatpak ?
the team at flatpak is very friendly and assistive especially when a package upstream is involved ... well you are the creator of this great package ... you'll get all the help you may need from the flatpak team.

Also i am a free lance designer ... i would like to contribute towards your GUI plans to incorporate the functions of shortcuts ... just let me know if you'd be interested ... and i'll try and work a UI that'll complement the current simplistic elegance of your package ... you can find me on https://t.me/deepin with the same username as github.

@rom1v
Copy link
Collaborator

rom1v commented Aug 13, 2019

I was wondering if you'd package your app as a flatpak ?

See #486.

i would like to contribute towards your GUI plans to incorporate the functions of shortcuts

Thank you for your proposal.

Adding a control bar is cumbersome in SDL. It would be easier in Qt.

A (long-term) path I have in mind to add a control bar is:

  1. refactor to expose the "engine" as a lib (libscrcpy)
  2. make the (current) SDL app use the lib (I want to keep the SDL version because it is very light)
  3. implement another UI in Qt, also using libscrcpy, to get a UI similar to QtScrcpy #612

@aiamuzz
Copy link
Author

aiamuzz commented Aug 13, 2019

I was wondering if you'd package your app as a flatpak ?

See #486.

i would like to contribute towards your GUI plans to incorporate the functions of shortcuts

Thank you for your proposal.

Adding a control bar is cumbersome in SDL. It would be easier in Qt.

A (long-term) path I have in mind to add a control bar is:

  1. refactor to expose the "engine" as a lib (libscrcpy)
  2. make the (current) SDL app use the lib (I want to keep the SDL version because it is very light)
  3. implement another UI in Qt, also using libscrcpy, to get a UI similar to QtScrcpy #612

have posted on the flatpak thread ...

that's a nice implementation by barry ... so do drop in a word when you finally implement libsccpy ... will be glad to help .

@dedosmedia
Copy link
Contributor

Hi @rom1v
Is libscrcpy still in your roadmap?

@rom1v
Copy link
Collaborator

rom1v commented Dec 14, 2019

It is something I'd like to do. But I probably won't work on libscrcpy in the short term.

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

No branches or pull requests

4 participants