-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Doesn't work after upgrading to Android 14 #4467
Comments
Are you sure? These problems in scrcpy 2.2 have been fixed in 2.3. |
I downloaded the scrcpy-win64-v2.3.zip from GitHub and my --version is this:
|
Could you please try v2.2? What aee the error messages in the output? (are there tthe same?) |
When using Version 2.2 the normal screen share, audio share and using the pc to klick on the phone works just fine. However I still cannot access the camera:
|
Thank you. Please post your
|
Some added code in the vendor ROM (samsung-specific code) which causes issue if if (CoreRune.MT_SUPPORT_COMPAT_SANDBOX) {
ActivityThread thread = ActivityThread.currentActivityThread();
Configuration currentConfig = thread != null ? thread.getConfiguration() : null;
if (CompatSandbox.isDisplaySandboxingEnabled(currentConfig)) { Let's try to set a fake configuration controller: diffdiff --git a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
index db9c96290..47c09b84e 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
@@ -91,6 +91,8 @@ public final class Workarounds {
if (mustFillAppContext) {
Workarounds.fillAppContext();
}
+
+ fillConfigurationController();
}
@SuppressWarnings("deprecation")
@@ -149,6 +151,22 @@ public final class Workarounds {
}
}
+ private static void fillConfigurationController() {
+ try {
+ Class<?> configurationControllerClass = Class.forName("android.app.ConfigurationController");
+ Class<?> activityThreadInternalClass = Class.forName("android.app.ActivityThreadInternal");
+ Constructor<?> configurationControllerConstructor = configurationControllerClass.getDeclaredConstructor(activityThreadInternalClass);
+ configurationControllerConstructor.setAccessible(true);
+ Object configurationController = configurationControllerConstructor.newInstance(ACTIVITY_THREAD);
+
+ Field configurationControllerField = ACTIVITY_THREAD_CLASS.getDeclaredField("mConfigurationController");
+ configurationControllerField.setAccessible(true);
+ configurationControllerField.set(ACTIVITY_THREAD, configurationController);
+ } catch (Throwable throwable) {
+ Ln.d("Could not fill configuration: " + throwable.getMessage());
+ }
+ }
+
static Context getSystemContext() {
try {
Method getSystemContextMethod = ACTIVITY_THREAD_CLASS.getDeclaredMethod("getSystemContext"); Replace this binary into your scrcpy 2.3 directory:
|
I get a 404 when trying to download the binary. |
Oops, link fixed. |
This works for the normal screen share mode, but the camera share still seems to be broken. Should I open another issue for this, since the main thing is solved? |
The error message for the camera is the same as in the original issue. |
I can't explain why you get a null context here. But maybe this will be sufficient: diffdiff --git a/server/src/main/java/com/genymobile/scrcpy/FakeContext.java b/server/src/main/java/com/genymobile/scrcpy/FakeContext.java
index 2ea7bf4af..fd3a3411a 100644
--- a/server/src/main/java/com/genymobile/scrcpy/FakeContext.java
+++ b/server/src/main/java/com/genymobile/scrcpy/FakeContext.java
@@ -4,6 +4,7 @@ import android.annotation.TargetApi;
import android.content.AttributionSource;
import android.content.Context;
import android.content.ContextWrapper;
+import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Process;
@@ -50,4 +51,9 @@ public final class FakeContext extends ContextWrapper {
public Context getApplicationContext() {
return this;
}
+
+ @Override
+ public int checkSelfPermission(String permission) {
+ return PackageManager.PERMISSION_GRANTED;
+ }
}
Replace this binary into your scrcpy 2.3 directory:
|
Unfortunately, I still get this error:
|
OK, let's add some logs: diffdiff --git a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
index db9c96290..14361c6dd 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
@@ -152,10 +152,12 @@ public final class Workarounds {
static Context getSystemContext() {
try {
Method getSystemContextMethod = ACTIVITY_THREAD_CLASS.getDeclaredMethod("getSystemContext");
- return (Context) getSystemContextMethod.invoke(ACTIVITY_THREAD);
+ Context context = (Context) getSystemContextMethod.invoke(ACTIVITY_THREAD);
+ Ln.i("=== " + context);
+ return context;
} catch (Throwable throwable) {
// this is a workaround, so failing is not an error
- Ln.d("Could not get system context: " + throwable.getMessage());
+ Ln.e("Could not get system context: ", throwable);
return null;
}
} Replace this binary into your scrcpy 2.3 directory:
Please post the full console output when you mirror the device and when you mirror the camera (both will fail, but I want the output). |
|
Thank you. One more time with this one please (for both device and camera mirroring): diffdiff --git a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
index db9c96290..1006d73c2 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
@@ -91,6 +91,8 @@ public final class Workarounds {
if (mustFillAppContext) {
Workarounds.fillAppContext();
}
+
+ fillConfigurationController();
}
@SuppressWarnings("deprecation")
@@ -149,13 +151,31 @@ public final class Workarounds {
}
}
+ private static void fillConfigurationController() {
+ try {
+ Class<?> configurationControllerClass = Class.forName("android.app.ConfigurationController");
+ Class<?> activityThreadInternalClass = Class.forName("android.app.ActivityThreadInternal");
+ Constructor<?> configurationControllerConstructor = configurationControllerClass.getDeclaredConstructor(activityThreadInternalClass);
+ configurationControllerConstructor.setAccessible(true);
+ Object configurationController = configurationControllerConstructor.newInstance(ACTIVITY_THREAD);
+
+ Field configurationControllerField = ACTIVITY_THREAD_CLASS.getDeclaredField("mConfigurationController");
+ configurationControllerField.setAccessible(true);
+ configurationControllerField.set(ACTIVITY_THREAD, configurationController);
+ } catch (Throwable throwable) {
+ Ln.d("Could not fill configuration: " + throwable.getMessage());
+ }
+ }
+
static Context getSystemContext() {
try {
Method getSystemContextMethod = ACTIVITY_THREAD_CLASS.getDeclaredMethod("getSystemContext");
- return (Context) getSystemContextMethod.invoke(ACTIVITY_THREAD);
+ Context context = (Context) getSystemContextMethod.invoke(ACTIVITY_THREAD);
+ Ln.i("=== " + context);
+ return context;
} catch (Throwable throwable) {
// this is a workaround, so failing is not an error
- Ln.d("Could not get system context: " + throwable.getMessage());
+ Ln.e("Could not get system context: ", throwable);
return null;
}
}
|
It seems like the device sharing works and the camera still has the same error as in my last comment:
|
Oh ok thank you, I understand. I will propose a new binary to test tomorrow probably. |
OK, thank you for your help so far. |
Getting the same problem on macOS, also with a Samsung phone on Android 14:
|
On some Samsung devices, DisplayManagerGlobal.getDisplayInfoLocked() calls ActivityThread.currentActivityThread().getConfiguration(), which requires a non-null ConfigurationController. Fixes <#4467>
I think 140a49b can fix it. Please test:
|
this one works for me with android 14 |
@gbil Both the camera capture and the device screen capture? |
should had clarified, I'm able to test only the device part |
This works for me for Device Share and Camera Share. |
Fix 140a49b merged into |
Also experiencing this issue. Do I have to wait until next build to obtain this fix? Using the Windows release. Thanks in advance |
@moe7863 No, the fix is in the first post of this thread. |
Perfect, sorted thank you! |
same(?) error on fedora linux. Samsung 14 android. Tried compile dev branch
|
Did you also compile the server? ( Instead, download |
OK, just to confirm, the binary shared in the 1st post is working on MacOS Sonoma. I had installed using brew, and upgraded from 2.2 to 2.3 and g=faced the exact issue as described by OP.
|
Also works for me. upgraded the server in my brew installation. When do you plan to release it? |
I will probably publish a 2.3.1 "soon". |
Fixed in 2.3.1. |
I had earlier the same error code then I make below steps, because fix was merged.
after update process finished I just run:
however on the start error code appear:
similar/the same error code also appear after click on anything:
I tried also check: scrcpy-server from first post, however for now I had errors about incompatibility client with server. |
Thanks! Great, works without any problems! |
On Win11 this week my keyboard and mouse stopped working, Samsung A13. Updated the files with the latest version from last month. Back OK now, yeah. Glad it's solved. |
I'll add that scrcpy does manage to turn my Pixel 7's screen off before it crashes
|
This may have fixed the previous version, but it's definitely broken in Android build# AP21.240119.009 security update Feb 5th 2024 Should I start a new issue or will this one be reopened? |
I am using an old Mac (10.14.6) and can only get scrcpy up to v1.24. May I know if there is a way to get the scrcpy to work with Android 14? Thanks! |
Why? |
In my hands, brew update does not work. But I do confirm that MacPorts install/ update works for macOS 10.14.6 Therefore, the problem is solved. Thanks for your attention. |
Environment
Describe the bug
After upgrading my phone to Android 14 (from Android 13) scrcpy stopped working with the following error.
I also tried no-audio and all available encoders. Before the upgrade, it worked just fine.
Also, if I do video-source camera, I get a different error as below. I do not know whether the two things are related. Before upgrading, I could not access all cameras (either not listed or instantly disconnecting without error message) but only two, now this error occurs all the time.
EDIT by @rom1v: fixed in scrcpy 2.3.1.
old
This will be fixed in the next version.Meanwhile, replace this file in the scrcpy 2.3 directory:
scrcpy-server
SHA-256: d3a1e798c490dd85e4bac19d5fb95b748f34f13c84676ddaa1f661ddb7ffc7e1
The text was updated successfully, but these errors were encountered: