-
-
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
New camera feature issues on some devices #4392
Comments
|
Please try to force
|
I have tried the camera feature with a OnePlus 7 and a Fold 4. It works fine on the Fold, but got the same error on the OnePlus 7. I haven't compiled it yet with the change. |
My device is Redmi Note 11T Pro(
|
I've tried the same on Poco F4 (much) running on Evolution X A13 which is also having the same issue (traceback attached below). Available cameras
Starting camera
|
OS: MacOS Ventura 13.4 (Intel CPU) |
Thank you for your reports and stack traces 👍 So, that's great: each reported device here fails in a different way (different stack trace). 🙃 Please post your
|
framework.jar.zip |
Ahah, it seems they lie to pass the CTS 😆 String packageName = ActivityThread.currentOpPackageName();
String device_build_name = Build.DEVICE;
if (packageName.equals("com.android.cts.verifier") && device_build_name.contains("xaga")) { But since
This might be the same problem in the stacktrace from @arunpt:
Could you please try with this quick-and-dirty patch: diff --git a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
index b8ee68ca5..a3330c160 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
@@ -123,6 +123,16 @@ public final class Workarounds {
ApplicationInfo applicationInfo = new ApplicationInfo();
applicationInfo.packageName = FakeContext.PACKAGE_NAME;
+ Application application = new Application() {
+ @Override
+ public String getOpPackageName() {
+ return FakeContext.PACKAGE_NAME;
+ }
+ };
+ Field initialApplicationField = activityThreadClass.getDeclaredField("mInitialApplication");
+ initialApplicationField.setAccessible(true);
+ initialApplicationField.set(activityThread, application);
+
// appBindData.appInfo = applicationInfo;
Field appInfoField = appBindDataClass.getDeclaredField("appInfo");
appInfoField.setAccessible(true); |
Hello, The
And I find some other issues about |
And this is my |
framework.jar.munch.zip |
Some more quick-and-dirty hacks, please test branch |
Thanks, but there is error too.🙃
|
I'm very surprised that you get this error on that branch. Could you please log what context you retrieve to pass to the FakeContext constructor, with this additional diff: diff --git a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
index 37240246e..e31b598d0 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Workarounds.java
@@ -327,7 +327,9 @@ public final class Workarounds {
static Context retrieveSystemContext() {
try {
Method getSystemContextMethod = activityThreadClass.getDeclaredMethod("getSystemContext");
- return (Context) getSystemContextMethod.invoke(activityThread);
+ Context ctx = (Context) getSystemContextMethod.invoke(activityThread);
+ Ln.i("===== " + ctx);
+ return ctx;
} catch (Exception e) {
Ln.e("Cannot retrieve system context", e);
return null; |
I just tried this diff, but the error message returned did not change anything. I don't know java but I guess the error may have occurred earlier. |
I got a different error which wasn't mentioned yet on my OnePlus 8T using Lineage for microG 20 (Android 13) scrcpy --list-cameras
scrcpy v2.2 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO: --> (usb) 35311d0d device KB2003
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 777.2 MB/s (64363 bytes in 0.000s)
[server] INFO: Device: [OnePlus] OnePlus KB2003 (Android 13)
[server] ERROR: Attempt to invoke virtual method 'android.content.res.Resources android.app.Application.getResources()' on a null object reference
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.app.Application.getResources()' on a null object reference
at android.hardware.Camera.shouldExposeAuxCamera(Camera.java:282)
at android.hardware.camera2.CameraManager$CameraManagerGlobal.onStatusChangedLocked(CameraManager.java:2298)
at android.hardware.camera2.CameraManager$CameraManagerGlobal.connectCameraServiceLocked(CameraManager.java:1713)
at android.hardware.camera2.CameraManager$CameraManagerGlobal.getCameraIdList(CameraManager.java:1931)
at android.hardware.camera2.CameraManager.getCameraIdList(CameraManager.java:246)
at com.genymobile.scrcpy.LogUtils.buildCameraListMessage(LogUtils.java:91)
at com.genymobile.scrcpy.Server.internalMain(Server.java:228)
at com.genymobile.scrcpy.Server.main(Server.java:190)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355) Edit: Using branch |
@zxc7895531 I updated EDIT: then please test |
I just tried now,
And there is another issues about
|
👍 and |
It cannot use too😓 |
What about |
|
Let's rework the app/context/system context, and retry: |
Environment
Attempting to use other camera id's presents similar console messages. console
|
Finnaly, it's all work great👍 |
@zxc7895531 for reference and investigations https://stackoverflow.com/questions/61800594/detect-all-cameras-android |
@zxc7895531 Could you please execute |
I use Ubuntu, so my scrcpy version is not updated, so I install it via github |
Yes, but download the file linked in the first post (with the fix attempt):
And execute the commands I posted in my previous comment: export SCRCPY_SERVER_PATH=path/to/the/scrcpy-server # adapt the path
scrcpy --list-cameras |
I was able to reproduce the same. I passed camera ids 3 and 4 to open my wide angle and macro lenses, but the |
@arunpt Could you also test |
@zxc7895531 @arunpt I just pushed a new branch
I could not test it myself, none of my device support logical multi-camera apparently. Please post the output you get in the console when you execute |
|
@arunpt OK, I don't know how to list all your cameras then.
Where is this special code? After a quick look at the framework.jar provided, I didn't find it. |
@rom1v I think there are two small issues preventing this from working:
After making the two changes (I just hardcoded the physical camera ID when testing), it's working fine on my Pixel 8 Pro. This is what the system exposes on the device:
If you decide to implement this, I think we'll need a |
Oh, indeed, good catch 👍 Fixed on @zxc7895531 What is the result of Indeed, on a Pixel 6a, I correctly get:
Apparently, it can on some devices: #4392 (comment)
So I think the current branch We could add physical camera handling later (is it really important?), but maybe I could publish a v2.2.1 soon with the fixes of the branch |
Thanks! I overlooked that comment. Looks like one more item to add to the list of things that don't follow the documented behavior 🙁
EDIT:
The one situation I could think of where it might be a dealbreaker is if there's a device where the logical camera defaults to a physical camera that's not useful for normal use (eg. telephoto). I don't know if any device behaves like this in practice. |
I pushed a couple commits to my branch (commits cd6d9f6 and ea91d85) for a proof-of-concept implementation of selecting a physical camera. This branch allows |
In
private String[] extractCameraIdListLocked() {
int size = Camera.shouldExposeAuxCamera() ? this.mDeviceStatus.size() : 2;
int i = 0;
for (int i2 = 0; i2 < size; i2++) {
int intValue = this.mDeviceStatus.valueAt(i2).intValue();
if (intValue != 0 && intValue != 2) {
i++;
}
}
String[] strArr = new String[i];
int i3 = 0;
for (int i4 = 0; i4 < size; i4++) {
int intValue2 = this.mDeviceStatus.valueAt(i4).intValue();
if (intValue2 != 0 && intValue2 != 2) {
strArr[i3] = this.mDeviceStatus.keyAt(i4);
i3++;
}
}
return strArr;
}
public static boolean shouldExposeAuxCamera() {
String currentOpPackageName = ActivityThread.currentOpPackageName();
if (currentOpPackageName == null) {
return true;
}
ArrayList arrayList = new ArrayList(Arrays.asList(SystemProperties.get("vendor.camera.aux.packagelist", ",").split(",")));
ArrayList arrayList2 = new ArrayList(Arrays.asList(SystemProperties.get("vendor.camera.aux.packageexcludelist", ",").split(",")));
Resources resources = ActivityThread.currentApplication().getResources();
arrayList.addAll(Arrays.asList(resources.getStringArray(C3639R.array.config_cameraAuxPackageAllowList)));
arrayList2.addAll(Arrays.asList(resources.getStringArray(C3639R.array.config_cameraAuxPackageExcludeList)));
return (arrayList.isEmpty() || arrayList.contains(currentOpPackageName)) && !arrayList2.contains(currentOpPackageName);
} That's why it requires LineageOS has an almost identical version, I wonder who started it: private String[] extractCameraIdListLocked() {
String[] cameraIds = null;
boolean exposeAuxCamera = Camera.shouldExposeAuxCamera();
int idCount = 0;
for (int i = 0; i < mDeviceStatus.size(); i++) {
if (!exposeAuxCamera && i == 2) break;
int status = mDeviceStatus.valueAt(i);
if (status == ICameraServiceListener.STATUS_NOT_PRESENT
|| status == ICameraServiceListener.STATUS_ENUMERATING) continue;
idCount++;
}
cameraIds = new String[idCount];
idCount = 0;
for (int i = 0; i < mDeviceStatus.size(); i++) {
if (!exposeAuxCamera && i == 2) break;
int status = mDeviceStatus.valueAt(i);
if (status == ICameraServiceListener.STATUS_NOT_PRESENT
|| status == ICameraServiceListener.STATUS_ENUMERATING) continue;
cameraIds[idCount] = mDeviceStatus.keyAt(i);
idCount++;
}
return cameraIds;
} public static boolean shouldExposeAuxCamera() {
/**
* Force to expose only two cameras
* if the package name does not falls in this bucket
*/
String packageName = ActivityThread.currentOpPackageName();
List<String> packageList = new ArrayList<>(Arrays.asList(
SystemProperties.get("vendor.camera.aux.packagelist", ",").split(",")));
List<String> packageExcludelist = new ArrayList<>(Arrays.asList(
SystemProperties.get("vendor.camera.aux.packageexcludelist", ",").split(",")));
// Append packages from lineage-sdk resources
Resources res = ActivityThread.currentApplication().getResources();
packageList.addAll(Arrays.asList(res.getStringArray(
org.lineageos.platform.internal.R.array.config_cameraAuxPackageAllowList)));
packageExcludelist.addAll(Arrays.asList(res.getStringArray(
org.lineageos.platform.internal.R.array.config_cameraAuxPackageExcludeList)));
return (packageList.isEmpty() || packageList.contains(packageName)) &&
!packageExcludelist.contains(packageName);
} Using
|
@yume-chan Thank you very much 👍 So the problem in #4392 (comment) is not related to physical cameras. It just happened to list all cameras when the package name was not set (for some reason), as you said. We cannot write to system properties (permission denied), and I'm not very keen to create a custom So I guess it will remain that way, sorry :/ |
Fixes pushed to |
I forgot I can get camera list from camera service directly: https://github.com/Genymobile/scrcpy/compare/cameraphy.3...yume-chan:feat/raw-camera-id?expand=1 Prebuilt: scrcpy-server.zip
ID 0 and 1 was there previously and works, 2 and 3 weren't there but also works. For ID 4 and 5
For ID 6 and 7
(It stops here) For ID 8
It looks like none of those logical cameras works. |
is there anyway to undo this fix as a user? i want to list all the lenses on my device ( including the wide angle lens in my case ). |
The missing cameras issue is fixed on |
Environment
Describe the bug
I'm attempting to use the new camera feature on my OnePlus. I used the pre-built server and then manually built the client. The main phone screen display works fine, but I get the following message when I attempt to use the camera mirroring feature:
Attempting to use other camera id's presents similar console messages.
EDIT by @rom1v: it is now fixed, upgrade to version 2.3.
old
EDIT by @rom1v: the problem will be fixed in the next release.Meanwhile, you can download this file and replace it in the release of scrcpy v2.2:
scrcpy-server
SHA-256: 97423bebd9e897f27ae4c0e81699e7cd04338c1a84d0fa9995d2ce29f9fc8bce
(built from branch
camerafix
)Please tell us if it fixes your problem or not (or if it creates other issues).
The text was updated successfully, but these errors were encountered: