Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
108.58k stars 10.45k forks source link

ERROR: Exception on thread Thread[video,5,main] #4922

Closed Kimi1860 closed 1 month ago

Kimi1860 commented 3 months ago

Environment

Describe the bug

image

On errors, please provide the output of the console (and adb logcat if relevant).

Please paste terminal output in a code block.

Please do not post screenshots of your terminal, just post the content as text instead.

rom1v commented 3 months ago

The vendor rom calls an internal "Sky-something", which fails.

Could you please post your framework.jar?

adb pull /system/framework/framework.jar
Kimi1860 commented 3 months ago

framework.jar.zip Here's the framework.jar

Thanks

Kimi1860 commented 3 months ago

Hi, I've post the framework.jar. Just wonder if there's any chance that my devices could be available to connect with this.

rom1v commented 3 months ago

It's weird, your framework.jar is almost empty, it doesn't contains the expected classes.

Kimi1860 commented 3 months ago

The OS provider is called Coocaa, maybe they did some tricks reconstructed the framework

xtbbbbdx commented 2 months ago

Same issue. Also happen at Skyworth TV, Looks like it's common issue on Skyworth TV

HinsCoder commented 2 months ago

My Skyworth Coocaa TV is the same issue.I tried to downgrade to scrcpy v1.19 and resolved the issue.But its maximum resolution can only be set to 1920 x 1080, and its HDMI channel is black screen (appears to have DRM protection?)

rom1v commented 2 months ago

I tried to downgrade to scrcpy v1.19 and resolved the issue.

With the latest version, does it work if you disable audio (scrcpy --no-audio)? What is the exact error you get (the full console output)?

HinsCoder commented 2 months ago

I tried to downgrade to scrcpy v1.19 and resolved the issue.

With the latest version, does it work if you disable audio (scrcpy --no-audio)? What is the exact error you get (the full console output)?

I just tried, but this error still persists.

C:\Users\Hins\Downloads\scrcpy-win64-v2.5>scrcpy --no-audio
scrcpy 2.5 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     --> (tcpip)  192.168.31.22:5555              device  7T872_P60P
C:\Users\Hins\Downloads\scrcpy-win64-v2.5\scrcpy...ed, 0 skipped. 86.8 MB/s (69624 bytes in 0.001s)
[server] INFO: Device: [skyworth] Coocaa 7T872_P60P (Android 10)
[server] ERROR: Exception on thread Thread[video,5,main]
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
        at android.media.MediaCodec.getCurProcessName(MediaCodec.java:1913)
        at android.media.MediaCodec.setSkyMediaStatus(MediaCodec.java:1927)
        at android.media.MediaCodec.release(MediaCodec.java:1949)
        at com.genymobile.scrcpy.SurfaceEncoder.streamCapture(SurfaceEncoder.java:95)
        at com.genymobile.scrcpy.SurfaceEncoder.lambda$start$0$com-genymobile-scrcpy-SurfaceEncoder(SurfaceEncoder.java:257)
        at com.genymobile.scrcpy.SurfaceEncoder$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
        at java.lang.Thread.run(Thread.java:919)
INFO: Renderer: direct3d
ERROR: Controller error
DancingDolphins commented 2 months ago

same here and my framework.jar.zip

for 1.19 is OK

D:\scrcpy\scrcpy-win64-v1.19>scrcpy.exe
INFO: scrcpy 1.19 <https://github.com/Genymobile/scrcpy>
D:\scrcpy\scrcpy-win64-v1.19\scrcpy-server: 1 file pushed, 0 skipped. 28.1 MB/s (37330 bytes in 0.001s)
[server] INFO: Device: Skyworth 1AA03_BC20 (Android 9)
INFO: Renderer: direct3d
INFO: Initial texture: 1920x1080

for 1.20 is error

D:\scrcpy\scrcpy-win64-v1.20>scrcpy.exe
INFO: scrcpy 1.20 <https://github.com/Genymobile/scrcpy>
D:\scrcpy\scrcpy-win64-v1.20\scrcpy-server: 1 file pushed, 0 skipped. 33.9 MB/s (37139 bytes in 0.001s)
[server] INFO: Device: Skyworth 1AA03_BC20 (Android 9)
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
        at android.media.MediaCodec.getCurProcessName(MediaCodec.java:3885)
        at android.media.MediaCodec.setSkyMediaStatus(MediaCodec.java:3898)
        at android.media.MediaCodec.<init>(MediaCodec.java:1810)
        at android.media.MediaCodec.createEncoderByType(MediaCodec.java:1787)
        at com.genymobile.scrcpy.ScreenEncoder.createCodec(ScreenEncoder.java:176)
        at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:74)
        at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:65)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:80)
        at com.genymobile.scrcpy.Server.main(Server.java:255)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:351)
ERROR: "adb reverse --remove" returned with value 1
ERROR: Could not retrieve device information

D:\scrcpy\scrcpy-win64-v1.20>

for 2.5

D:\scrcpy\scrcpy-win64-v2.5>scrcpy.exe --tcpip=192.168.89.145
scrcpy 2.5 <https://github.com/Genymobile/scrcpy>
INFO: Connecting to 192.168.89.145:5555...
INFO: Connected to 192.168.89.145:5555
D:\scrcpy\scrcpy-win64-v2.5\scrcpy-server: 1 file pushed, 0 skipped. 92.5 MB/s (69624 bytes in 0.001s)
[server] INFO: Device: [Skyworth] Skyworth 1AA03_BC20 (Android 9)
[server] WARN: Audio disabled: it is not supported before Android 11
[server] ERROR: Exception on thread Thread[video,5,main]
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
        at android.media.MediaCodec.getCurProcessName(MediaCodec.java:3885)
        at android.media.MediaCodec.setSkyMediaStatus(MediaCodec.java:3898)
        at android.media.MediaCodec.<init>(MediaCodec.java:1810)
        at android.media.MediaCodec.createEncoderByType(MediaCodec.java:1787)
        at com.genymobile.scrcpy.SurfaceEncoder.createMediaCodec(SurfaceEncoder.java:208)
        at com.genymobile.scrcpy.SurfaceEncoder.streamCapture(SurfaceEncoder.java:53)
        at com.genymobile.scrcpy.SurfaceEncoder.lambda$start$0$com-genymobile-scrcpy-SurfaceEncoder(SurfaceEncoder.java:257)
        at com.genymobile.scrcpy.SurfaceEncoder$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
        at java.lang.Thread.run(Thread.java:764)
ERROR: "adb reverse --remove" returned with value 1
ERROR: Could not retrieve device information
ERROR: Server connection failed
rom1v commented 2 months ago

Between 1.19 and 1.20, this is probably due to this commit 8df42cec82cb5856e6c10a4089e6b2953310da6e.

Let's try with this quick&dirty change:

diff --git a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
index 448e7099f..db0d72789 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
@@ -74,6 +74,9 @@ public final class Workarounds {
             mustFillAppContext = true;
         }

+        mustFillAppInfo = true;
+        mustFillAppContext = true;
+
         if (audio && Build.VERSION.SDK_INT == Build.VERSION_CODES.R) {
             // Before Android 11, audio is not supported.
             // Since Android 12, we can properly set a context on the AudioRecord.

Replace this file in your v2.5 release:

HinsCoder commented 2 months ago

Replace this file in your v2.5 release:

  • scrcpy-server SHA-256: 55926d71d45aef83d989bf0fcd25801f8886307efe933eb8d4200807890080a

This is an effective modification, thank you very much!

image

rom1v commented 2 months ago

Oh great!

Could you then test this new one and confirm that it works:

Here is the diff:

diff --git a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
index 448e7099f..3f86f892b 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
@@ -63,7 +63,7 @@ public final class Workarounds {
             //  - <https://github.com/Genymobile/scrcpy/issues/940>
             //  - <https://github.com/Genymobile/scrcpy/issues/994>
             mustFillAppInfo = true;
-        } else if (Build.BRAND.equalsIgnoreCase("honor")) {
+        } else if (Build.BRAND.equalsIgnoreCase("honor") || Build.BRAND.equalsIgnoreCase("skyworth")) {
             // More workarounds must be applied for Honor devices:
             //  - <https://github.com/Genymobile/scrcpy/issues/4015>
             //
HinsCoder commented 2 months ago

Could you then test this new one and confirm that it works:

  • scrcpy-server SHA-256: 7cb3bc939c91e23788ed3f2801f71b9cc8f258e85bed7b60fc98ece9721bbe1

Oh no, the NullPointerException error has occurred again.

C:\Users\Hins\Downloads\scrcpy-win64-v2.5>scrcpy
scrcpy 2.5 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     --> (tcpip)  192.168.31.22:5555              device  7T872_P60P
C:\Users\Hins\Downloads\scrcpy-win64-v2.5\scrcpy-server: 1...ile pushed, 0 skipped. 111.2 MB/s (164344 bytes in 0.001s)
[server] INFO: Device: [skyworth] Coocaa 7T872_P60P (Android 10)
[server] WARN: Audio disabled: it is not supported before Android 11
INFO: Renderer: direct3d
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Texture: 1920x1080
ERROR: Controller error
[server] ERROR: Exception on thread Thread[video,5,main]
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
        at android.media.MediaCodec.getCurProcessName(MediaCodec.java:1913)
        at android.media.MediaCodec.setSkyMediaStatus(MediaCodec.java:1927)
        at android.media.MediaCodec.release(MediaCodec.java:1949)
        at com.genymobile.scrcpy.SurfaceEncoder.streamCapture(SurfaceEncoder.java:95)
        at com.genymobile.scrcpy.SurfaceEncoder.lambda$start$0$com-genymobile-scrcpy-SurfaceEncoder(SurfaceEncoder.java:257)
        at com.genymobile.scrcpy.SurfaceEncoder$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
        at java.lang.Thread.run(Thread.java:919)
rom1v commented 2 months ago

Device: [skyworth] Coocaa 7T872_P60P (Android 10)

Oh in your case, the manufacturer is still skyworth, but the brand is Coocaa. Let's test the manufacturer instead:

diff --git a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
index 999f6a714..c9a26d787 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
@@ -63,7 +63,7 @@ public final class Workarounds {
             //  - <https://github.com/Genymobile/scrcpy/issues/940>
             //  - <https://github.com/Genymobile/scrcpy/issues/994>
             mustFillAppInfo = true;
-        } else if (Build.BRAND.equalsIgnoreCase("honor") || Build.BRAND.equalsIgnoreCase("skyworth")) {
+        } else if (Build.BRAND.equalsIgnoreCase("honor") || Build.MANUFACTURER.equalsIgnoreCase("skyworth")) {
             // More workarounds must be applied for Honor devices:
             //  - <https://github.com/Genymobile/scrcpy/issues/4015>
             // and Skyworth devices:
HinsCoder commented 2 months ago

Oh in your case, the manufacturer is still skyworth, but the brand is Coocaa. Let's test the manufacturer instead:

Congratulate, it works successful again.

rom1v commented 2 months ago

:+1:

Merged into dev: b50f9eb41d1bd7b75a77e2c388b0144365e3cd5f :rocket: