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

Native crash in app_process : signal 11 (SIGSEGV) on Pixel Fold Android 14 #4624

Open
2 tasks done
AlexBurdu opened this issue Jan 29, 2024 · 15 comments
Open
2 tasks done

Comments

@AlexBurdu
Copy link
Contributor

AlexBurdu commented Jan 29, 2024

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

  • OS: macOS or Ubuntu (same issue on both)
  • scrcpy version: 2.3.1
  • installation method: manual build
  • device model: Pixel Fold
  • Android version: 14

Describe the bug
I am able to connect to the phone using scrcpy and everything works ok while the connection is kept.
The problem appears after I interrupt scrcpy and disconnect the phone. After a period of time, the phone freezes and reboots after a few minutes.

Cmdline: app_process / com.genymobile.scrcpy.CleanUp AAAAAAAAAAACAAAA
pid: 27362, tid: 27362, name: Shutdown thread  >>> app_process <<<
uid: 2000
tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x000000711ea22260
    x0  000000740e1e4b78  x1  0000000000001000  x2  0000000000000001  x3  0000007fdfc65f68
    x4  0000000000000058  x5  0000007287263bfc  x6  0000000000000001  x7  0000018600000249
    x8  000000711ea22264  x9  0000000000000001  x10 0000000000000002  x11 0000007415bdf000
    x12 00000000000035dd  x13 0000000000001b9c  x14 0000000000000018  x15 0000000000000000
    x16 0000007415782c00  x17 0000007415776310  x18 000000741d76e000  x19 0000000000000000
    x20 0000007415bdf6e4  x21 000000740e1e4b78  x22 0000000000001000  x23 00000074013b0a90
    x24 0000007415bdf000  x25 00000000000040b0  x26 0000000000000692  x27 00000000000002b2
    x28 0000000000004000  x29 0000007fdfc65fd0
    lr  00000074157788f4  sp  0000007fdfc65fa0  pc  00000074013b0a94  pst 0000000080001000

4 total frames
backtrace:
      #00 pc 0000000000017a94  /system/lib64/libutils.so (android::String16::~String16()+4) (BuildId: 4ce5249405dff1a8480d738901c940d4)
      #01 pc 00000000000cd8f0  /apex/com.android.runtime/lib64/bionic/libc.so (__cxa_finalize+144) (BuildId: 19c32900d9d702c303d2b4164fbba76c)
      #02 pc 00000000000bfa98  /apex/com.android.runtime/lib64/bionic/libc.so (exit+24) (BuildId: 19c32900d9d702c303d2b4164fbba76c)
      #03 pc 00000000000546ec  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+108) (BuildId: 19c32900d9d702c303d2b4164fbba76c)
@rom1v
Copy link
Collaborator

rom1v commented Jan 30, 2024

Are you sure this backtrace appears with scrcpy v2.3.1 (i.e. that it was not generated from a version earlier than v2.2)?

It should not crash that way since v2.2, see discussion: #4456 (comment)

Clean your logs (adb logcat -c) and retry scrcpy v2.3.1.

@AlexBurdu
Copy link
Contributor Author

Hi @rom1v, thanks for responding!

I checkend again and the version is indeed 2.3.1. I just rebuilt it:

scrcpy 2.3.1

  User defined options
    buildtype: release
    strip    : true
    b_lto    : true

Found ninja-1.11.1 at /opt/homebrew/bin/ninja

In the issue that you linked the problem seems slightly different (not being able to turn off the display). In my case I can use scrcpy just fine for how long as I need. The problem appears after I disconnect it.

@AlexBurdu
Copy link
Contributor Author

--------- beginning of crash
01-30 17:18:41.332 17097 17097 F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x74c0faf260 in tid 17097 (Shutdown thread), pid 17097 (Shutdown thread)
01-30 17:18:41.475 17712 17712 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-30 17:18:41.475 17712 17712 F DEBUG   : Build fingerprint: 'google/felix/felix:14/UQ1A.240205.002/11224170:user/release-keys'
01-30 17:18:41.475 17712 17712 F DEBUG   : Revision: 'MP1.0'
01-30 17:18:41.475 17712 17712 F DEBUG   : ABI: 'arm64'
01-30 17:18:41.475 17712 17712 F DEBUG   : Timestamp: 2024-01-30 17:18:41.372581187+0200
01-30 17:18:41.475 17712 17712 F DEBUG   : Process uptime: 190s
01-30 17:18:41.475 17712 17712 F DEBUG   : Cmdline: app_process / com.genymobile.scrcpy.CleanUp AAAAAAAAAAACAAAA
01-30 17:18:41.475 17712 17712 F DEBUG   : pid: 17097, tid: 17097, name: Shutdown thread  >>> app_process <<<
01-30 17:18:41.475 17712 17712 F DEBUG   : uid: 2000
01-30 17:18:41.475 17712 17712 F DEBUG   : tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
01-30 17:18:41.475 17712 17712 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x00000074c0faf260
01-30 17:18:41.475 17712 17712 F DEBUG   :     x0  00000077bcdbeb80  x1  0000000000001000  x2  0000000000000001  x3  0000007fd7ff7558
01-30 17:18:41.475 17712 17712 F DEBUG   :     x4  0000000000000058  x5  000000768100debc  x6  0000000000000001  x7  00000249000003cf
01-30 17:18:41.475 17712 17712 F DEBUG   :     x8  00000074c0faf264  x9  0000000000000001  x10 0000000000000002  x11 00000077b033e000
01-30 17:18:41.475 17712 17712 F DEBUG   :     x12 0000000000000ba8  x13 0000000000001ba2  x14 0000000000000018  x15 0000000000000000
01-30 17:18:41.475 17712 17712 F DEBUG   :     x16 00000077afee1c00  x17 00000077afed5310  x18 00000077c18b2000  x19 0000000000000000
01-30 17:18:41.475 17712 17712 F DEBUG   :     x20 00000077b033e6e4  x21 00000077bcdbeb80  x22 0000000000001000  x23 00000077bb228a90
01-30 17:18:41.475 17712 17712 F DEBUG   :     x24 00000077b033e000  x25 00000000000040c8  x26 0000000000000693  x27 00000000000002b3
01-30 17:18:41.475 17712 17712 F DEBUG   :     x28 0000000000004000  x29 0000007fd7ff75c0
01-30 17:18:41.475 17712 17712 F DEBUG   :     lr  00000077afed78f4  sp  0000007fd7ff7590  pc  00000077bb228a94  pst 0000000080001000
01-30 17:18:41.475 17712 17712 F DEBUG   : 4 total frames
01-30 17:18:41.475 17712 17712 F DEBUG   : backtrace:
01-30 17:18:41.475 17712 17712 F DEBUG   :       #00 pc 0000000000017a94  /system/lib64/libutils.so (android::String16::~String16()+4) (BuildId: 4ce5249405dff1a8480d738901c940d4)
01-30 17:18:41.475 17712 17712 F DEBUG   :       #01 pc 00000000000cd8f0  /apex/com.android.runtime/lib64/bionic/libc.so (__cxa_finalize+144) (BuildId: 19c32900d9d702c303d2b4164fbba76c)
01-30 17:18:41.475 17712 17712 F DEBUG   :       #02 pc 00000000000bfa98  /apex/com.android.runtime/lib64/bionic/libc.so (exit+24) (BuildId: 19c32900d9d702c303d2b4164fbba76c)
01-30 17:18:41.475 17712 17712 F DEBUG   :       #03 pc 00000000000546ec  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+108) (BuildId: 19c32900d9d702c303d2b4164fbba76c)

@rom1v
Copy link
Collaborator

rom1v commented Jan 30, 2024

In the issue that you linked the problem seems slightly different (not being able to turn off the display).

The issue, yes, but the comment I pointed to is exactly your problem: a native crash on cleanup (when scrcpy disconnects).

However, in my case, it had no other impact than this stacktrace in logcat.

I checkend again and the version is indeed 2.3.1.

My bad, I checked the wrong commit. The fix is 1beec99, which is only on dev branch (it has been written after the 2.3.1 release).

@AlexBurdu
Copy link
Contributor Author

Thanks! When is the fix planned to be merged to main?

@rom1v
Copy link
Collaborator

rom1v commented Jan 30, 2024

Probably when #4473 is complete (it might take some time).

Meanwhile, you can build the dev branch.

@AlexBurdu
Copy link
Contributor Author

AlexBurdu commented Feb 1, 2024

I updated to dev branch and the issue is still reproducing (freeze and reboot after a few minutes from disconnecting scrcpy), but I'm no longer getting the relevant shutdown logs.

@AlexBurdu
Copy link
Contributor Author

Trying to pull relevant logs from the logcat. I'm trying to avoid uploading it here to not leak any private data. Let me know what may help investigate this.

02-01 06:30:17.532 31844 31844 I Choreographer: Skipped 477 frames!  The application may be doing too much work on its main thread.
02-01 06:30:17.574  1025 28259 I WifiHAL : Creating message to get link statistics; iface = 48
02-01 06:30:17.589 23049 26109 D HbmSvManager: Ambient sensor :  TMD3719 Ambient Light update Lux : 18.196802
02-01 06:30:17.624  1025 28259 I WifiHAL : In GetLinkStatsCommand::handleResponse
02-01 06:30:17.688 22493 22785 D ConnectivityService: NetReassign [no changes] [c 3] [a 4] [i 3]
02-01 06:30:18.212 23049 26109 D HbmSvManager: Ambient sensor :  TMD3719 Ambient Light update Lux : 15.961238
02-01 06:30:18.447 22493 22512 E BLASTSyncEngine: WM sent Transaction to organized, but never received commit callback. Application ANR likely to follow.
02-01 06:30:18.521 22493 22512 E BLASTSyncEngine: WM sent Transaction to organized, but never received commit callback. Application ANR likely to follow.
02-01 06:30:18.726 23049 26109 D HbmSvManager: Ambient sensor :  TMD3719 Ambient Light update Lux : 15.921528
02-01 06:30:18.749 23179 23179 I SHANNON_IMS: 2384 [PROX] Received onSignalStrengthsChanged [CellSignalStrengthLte: rssi=-69 rsrp=-93 rsrq=-6 rssnr=19 cqiTableIndex=1 cqi=14 ta=0 level=4 parametersUseForLevel=0] [SLID:1 APM:false] (ImsConnectivityProxyListener$ImsPhoneStateListener%onSignalStrengthsChanged:418)
02-01 06:30:18.827 23049 26109 D HbmSvManager: Ambient sensor :  TMD3719 Ambient Light update Lux : 15.814005
02-01 06:30:18.849 23049 26109 D HbmSvManager: Ambient sensor :  TMD3719 Ambient Light update Lux : 15.640277
02-01 06:30:19.155 20924 20955 W OpenGLRenderer: dequeueBuffer failed, error = -110; switching to fallback
02-01 06:30:19.172 20924 20924 I Choreographer: Skipped 478 frames!  The application may be doing too much work on its main thread.
02-01 06:36:47.084 22493 29968 E ActivityManager: Aborting stack trace dump (current firstPid=25337); deadline exceeded.
02-01 06:36:47.132 23049 26109 D HbmSvManager: Ambient sensor :  TMD3719 Ambient Light update Lux : 5.494851
02-01 06:36:47.176 23049 26109 D HbmSvManager: Ambient sensor :  TMD3719 Ambient Light update Lux : 5.424069
02-01 06:36:47.195 23049 26109 D HbmSvManager: Ambient sensor :  TMD3719 Ambient Light update Lux : 5.5267124
02-01 06:36:47.210 22493 29968 E ActivityManager: ANR in com.android.systemui
02-01 06:36:47.210 22493 29968 E ActivityManager: PID: 22858
02-01 06:36:47.210 22493 29968 E ActivityManager: Reason: Input dispatching timed out (2a846ec StatusBar (server) is not responding. Waited 5001ms for MotionEvent).
02-01 06:36:47.210 22493 29968 E ActivityManager: ErrorId: f0fc9d19-b061-4631-bed1-b39aab88cf5f
02-01 06:36:47.210 22493 29968 E ActivityManager: Frozen: false
02-01 06:36:47.210 22493 29968 E ActivityManager: Load: 2.75 / 2.05 / 3.0
02-01 06:36:47.210 22493 29968 E ActivityManager: ----- Output from /proc/pressure/memory -----
02-01 06:36:47.210 22493 29968 E ActivityManager: some avg10=0.44 avg60=0.13 avg300=0.20 total=293568597
02-01 06:36:47.210 22493 29968 E ActivityManager: full avg10=0.00 avg60=0.00 avg300=0.06 total=98617791
02-01 06:36:47.210 22493 29968 E ActivityManager: ----- End output from /proc/pressure/memory -----
02-01 06:36:47.210 22493 29968 E ActivityManager: ----- Output from /proc/pressure/cpu -----
02-01 06:36:47.210 22493 29968 E ActivityManager: some avg10=9.53 avg60=7.97 avg300=8.51 total=3248438186
02-01 06:36:47.210 22493 29968 E ActivityManager: ----- End output from /proc/pressure/cpu -----
02-01 06:36:47.210 22493 29968 E ActivityManager: ----- Output from /proc/pressure/io -----
02-01 06:36:47.210 22493 29968 E ActivityManager: some avg10=0.00 avg60=0.03 avg300=0.05 total=160230679
02-01 06:36:47.210 22493 29968 E ActivityManager: full avg10=0.00 avg60=0.00 avg300=0.00 total=81035465
02-01 06:36:47.210 22493 29968 E ActivityManager: ----- End output from /proc/pressure/io -----
02-01 06:36:47.210 22493 29968 E ActivityManager: 
02-01 06:36:47.210 22493 29968 E ActivityManager: CPU usage from 1ms to 21451ms later (2024-02-01 06:36:25.651 to 2024-02-01 06:36:47.102) with 99% awake:
02-01 06:36:47.210 22493 29968 E ActivityManager:   19% 22493/system_server: 10% user + 9.4% kernel / faults: 14100 minor 646 major
02-01 06:36:47.210 22493 29968 E ActivityManager:   8.9% 975/android.hardware.sensors-service.multihal: 3.5% user + 5.4% kernel / faults: 3 minor
02-01 06:36:47.210 22493 29968 E ActivityManager:   7.8% 604/surfaceflinger: 3.5% user + 4.2% kernel / faults: 66 minor 4 major
02-01 06:36:47.210 22493 29968 E ActivityManager:   7.5% 22387/android.hardware.camera.provider@2.7-service-google: 4.8% user + 2.6% kernel / faults: 2911 minor 351 major
02-01 06:36:47.210 22493 29968 E ActivityManager:   4.2% 552/sugov:4: 0% user + 4.2% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   4.1% 25232/adbd: 1% user + 3% kernel / faults: 514 minor
02-01 06:36:47.210 22493 29968 E ActivityManager:   0.1% 130/trusty-nop-7: 0% user + 0.1% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   3.3% 607/android.hardware.composer.hwc3-service.pixel: 0.8% user + 2.4% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   0.3% 93/kswapd0: 0% user + 0.3% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   0.1% 1172/android.hardware.biometrics.face-service-felix: 0% user + 0% kernel / faults: 1150 minor 1289 major
02-01 06:36:47.210 22493 29968 E ActivityManager: 14% TOTAL: 4.7% user + 7.8% kernel + 0% iowait + 1.1% irq + 0.6% softirq
02-01 06:36:47.210 22493 29968 E ActivityManager: CPU usage from 89ms to 993ms later (2024-02-01 06:36:25.739 to 2024-02-01 06:36:26.643):
02-01 06:36:47.210 22493 29968 E ActivityManager:   167% 22493/system_server: 88% user + 78% kernel / faults: 3148 minor 34 major
02-01 06:36:47.210 22493 29968 E ActivityManager:     97% 22499/Signal Catcher: 64% user + 32% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:     43% 29972/AnrAuxiliaryTas: 5.3% user + 37% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:     21% 22509/android.fg: 16% user + 5.3% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:     5.3% 22719/InputDispatcher: 2.6% user + 2.6% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:     2.6% 22671/SensorService: 2.6% user + 0% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   5.8% 975/android.hardware.sensors-service.multihal: 3.5% user + 2.3% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:     2.3% 1029/UsfHalWorker: 1.1% user + 1.1% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:     2.3% 1416/UsfTransport: 1.1% user + 1.1% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:     1.1% 1030/android.hardwar: 1.1% user + 0% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   4.5% 604/surfaceflinger: 2.2% user + 2.2% kernel / faults: 2 minor
02-01 06:36:47.210 22493 29968 E ActivityManager:     2.2% 604/surfaceflinger: 1.1% user + 1.1% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:     1.1% 726/TimerDispatch: 1.1% user + 0% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   2.2% 535/logd: 1.1% user + 1.1% kernel / faults: 41 minor
02-01 06:36:47.210 22493 29968 E ActivityManager:     1.1% 542/logd.writer: 0% user + 1.1% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   2.2% 553/sugov:6: 0% user + 2.2% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   1.1% 50/rcuop/4: 0% user + 1.1% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   1.1% 57/rcuop/5: 0% user + 1.1% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   1.1% 417/sched_pmu_wq: 0% user + 1.1% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   1.1% 551/sugov:0: 0% user + 1.1% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   1.1% 552/sugov:4: 0% user + 1.1% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   1.1% 607/android.hardware.composer.hwc3-service.pixel: 0% user + 1.1% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:     1.1% 607/binder:607_4: 0% user + 1.1% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   3% 23505/com.google.android.gms.persistent: 3% user + 0% kernel / faults: 26 minor
02-01 06:36:47.210 22493 29968 E ActivityManager:     3% 27062/lowpool[1363]: 3% user + 0% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager:   3.2% 24892/com.fitbit.FitbitMobile: 0% user + 3.2% kernel / faults: 1 minor
02-01 06:36:47.210 22493 29968 E ActivityManager:   3.3% 25232/adbd: 0% user + 3.3% kernel
02-01 06:36:47.210 22493 29968 E ActivityManager: 23% TOTAL: 11% user + 10% kernel + 0.2% iowait + 0.5% irq + 0.4% softirq
02-01 06:36:47.213 22493 29968 D ActivityManager: Completed ANR of com.android.systemui in 21564ms, latency 1ms
02-01 06:36:47.214 22493 22510 I ActivityManager: Killing 22858:com.android.systemui/u0a228 (adj -800): user request after error
02-01 06:36:47.220 22493 30114 I DropBoxManagerService: add tag=system_app_anr isTagEnabled=true flags=0x6
02-01 06:36:47.224 22493 22574 I libprocessgroup: Successfully killed process cgroup uid 10228 pid 22858 in 5ms
02-01 06:36:47.278 23049 26109 D HbmSvManager: Ambient sensor :  TMD3719 Ambient Light update Lux : 5.4885426
02-01 06:36:47.299 23049 26109 D HbmSvManager: Ambient sensor :  TMD3719 Ambient Light update Lux : 5.6376667
02-01 06:36:47.325  1159 14193 D BufferPoolAccessor2.0: bufferpool2 0xb4000073a1fa9e68 : 0(0 size) total buffers - 0(0 size) used buffers - 10/14 (recycle/alloc) - 4/13 (fetch/transfer)
02-01 06:36:47.325 22493 24024 I ActivityManager: Process com.android.systemui (pid 22858) has died: pers PERU
02-01 06:36:47.327  1946 19650 I android.hardware.biometrics.fingerprint-service.fpc42: onSysUiDeath()
02-01 06:36:47.329 22493 24028 E BiometricService: Enabled callback binder died
02-01 06:36:47.329 22493 24030 E LockoutResetTracker: Callback binder died: android.os.BinderProxy@7ba94ba
02-01 06:36:47.329 22493 24028 E LockoutResetTracker: Callback binder died: android.os.BinderProxy@59e2f6b
02-01 06:36:47.329 22493 24030 E LockoutResetTracker: Removing dead callback for: com.android.systemui
02-01 06:36:47.329 22493 24028 E LockoutResetTracker: Removing dead callback for: com.android.systemui
02-01 06:36:47.329  1946 19650 E IPCThreadState: attemptIncStrongHandle(2): Not supported

@rom1v
Copy link
Collaborator

rom1v commented Feb 1, 2024

I updated to dev branch and the issue is still reproducing (freeze and reboot after a few minutes from disconnecting scrcpy), but I'm no longer getting the relevant shutdown logs.

OK the the reboot was probably not directly related to this native crash.

Please test scrcpy --no-cleanup. Does the device reboot few minutes after you close?

@AlexBurdu
Copy link
Contributor Author

Issue does not reproduce with --no-cleanup

@rom1v
Copy link
Collaborator

rom1v commented Feb 1, 2024

OK, then another test:

  • run scrcpy --no-cleanup
  • in the scrcpy window, press Alt+o (to turn the screen off)
  • in the scrcpy window, press Alt+Shift+o (to turn the screen on)
  • exit

Does the device reboot few minutes later?

@AlexBurdu
Copy link
Contributor Author

Issue is reproducible with the above steps.

@AlexBurdu
Copy link
Contributor Author

Probably stating the obvious: this phone has 2 screens. Not sure how that impacts the functionality.

rom1v added a commit that referenced this issue Feb 5, 2024
Some actions may be performed when scrcpy exits, currently:
 - disable "show touches"
 - restore "stay on while plugged in"
 - power off screen
 - restore "power mode" (to disable "turn screen off")

They are performed from a separate process so that they can be executed
even when scrcpy-server is killed (e.g. if the device is unplugged).

The clean up actions to perform were configured when scrcpy started.
Given that there is no method to read the current "power mode" in
Android, and that "turn screen off" can be applied at any time using an
scrcpy shortcut, there was no way to determine if "power mode" had to be
restored on exit. Therefore, it was always restored to "normal", even
when not necessary.

However, setting the "power mode" is quite fragile on some devices, and
may cause some issues, so it is preferable to call it only when
necessary (when "turn screen off" has actually been called).

For that purpose, make the scrcpy-server main process and the clean up
process communicate the actions to perform over the stdout/stdin, so
that they can be changed dynamically. In particular, when the power mode
is changed at runtime, notify the clean up process.

Refs 1beec99
Refs #4456 <#4456>
Refs #4624 <#4624>
@rom1v
Copy link
Collaborator

rom1v commented Feb 5, 2024

This does not solve the underlying issue, but at least not setting the "power mode" when not necessary will limit the problem: #4649.

rom1v added a commit that referenced this issue Feb 5, 2024
Some actions may be performed when scrcpy exits, currently:
 - disable "show touches"
 - restore "stay on while plugged in"
 - power off screen
 - restore "power mode" (to disable "turn screen off")

They are performed from a separate process so that they can be executed
even when scrcpy-server is killed (e.g. if the device is unplugged).

The clean up actions to perform were configured when scrcpy started.
Given that there is no method to read the current "power mode" in
Android, and that "turn screen off" can be applied at any time using an
scrcpy shortcut, there was no way to determine if "power mode" had to be
restored on exit. Therefore, it was always restored to "normal", even
when not necessary.

However, setting the "power mode" is quite fragile on some devices, and
may cause some issues, so it is preferable to call it only when
necessary (when "turn screen off" has actually been called).

For that purpose, make the scrcpy-server main process and the clean up
process communicate the actions to perform over the stdout/stdin, so
that they can be changed dynamically. In particular, when the power mode
is changed at runtime, notify the clean up process.

Refs 1beec99
Refs #4456 <#4456>
Refs #4624 <#4624>
PR #4649 <#4649>
@AlexBurdu
Copy link
Contributor Author

AlexBurdu commented Feb 11, 2024

I haven't noticed any issues or disadvantages in mitigating the issue with --no-cleanup and not turning the screen on before disconnecting.

rom1v added a commit that referenced this issue Feb 17, 2024
Some actions may be performed when scrcpy exits, currently:
 - disable "show touches"
 - restore "stay on while plugged in"
 - power off screen
 - restore "power mode" (to disable "turn screen off")

They are performed from a separate process so that they can be executed
even when scrcpy-server is killed (e.g. if the device is unplugged).

The clean up actions to perform were configured when scrcpy started.
Given that there is no method to read the current "power mode" in
Android, and that "turn screen off" can be applied at any time using an
scrcpy shortcut, there was no way to determine if "power mode" had to be
restored on exit. Therefore, it was always restored to "normal", even
when not necessary.

However, setting the "power mode" is quite fragile on some devices, and
may cause some issues, so it is preferable to call it only when
necessary (when "turn screen off" has actually been called).

For that purpose, make the scrcpy-server main process and the clean up
process communicate the actions to perform over a pipe (stdin/stdout),
so that they can be changed dynamically. In particular, when the power
mode is changed at runtime, notify the clean up process.

Refs 1beec99
Refs #4456 <#4456>
Refs #4624 <#4624>
PR #4649 <#4649>
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