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

android.view.SurfaceControl.createDisplay seems to be removed #54

Closed
qua-iy opened this issue Apr 16, 2024 · 19 comments
Closed

android.view.SurfaceControl.createDisplay seems to be removed #54

qua-iy opened this issue Apr 16, 2024 · 19 comments

Comments

@qua-iy
Copy link

qua-iy commented Apr 16, 2024

What is the issue or idea you have?

I am testing Android 15 Beta 1 on STF, but minicap seems to be crashed on launch.
From logcat, it says java.lang.NoSuchMethodException: android.view.SurfaceControl.createDisplay [class java.lang.String, boolean], guessing certain internal API is removed from Android used inside minicap.
I found that related issue at scrcpy, with a commit to remove usage of same internal API.

I am not familiar with minicap and internal API, could anybody fix this issue?

Here are logs of logcat:

04-15 13:43:36.437 13748 13748 E SurfaceControl: SurfaceControl error
04-15 13:43:36.437 13748 13748 E SurfaceControl: java.lang.NoSuchMethodException: android.view.SurfaceControl.createDisplay [class java.lang.String, boolean]
04-15 13:43:36.437 13748 13748 E SurfaceControl: 	at java.lang.Class.getMethod(Class.java:2950)
04-15 13:43:36.437 13748 13748 E SurfaceControl: 	at java.lang.Class.getMethod(Class.java:2450)
04-15 13:43:36.437 13748 13748 E SurfaceControl: 	at io.devicefarmer.minicap.utils.SurfaceControl.createDisplay(SurfaceControl.kt:93)
04-15 13:43:36.437 13748 13748 E SurfaceControl: 	at io.devicefarmer.minicap.provider.SurfaceProvider.initSurface(SurfaceProvider.kt:87)
04-15 13:43:36.437 13748 13748 E SurfaceControl: 	at io.devicefarmer.minicap.provider.SurfaceProvider.initSurface(SurfaceProvider.kt:106)
04-15 13:43:36.437 13748 13748 E SurfaceControl: 	at io.devicefarmer.minicap.provider.SurfaceProvider.onConnection(SurfaceProvider.kt:75)
04-15 13:43:36.437 13748 13748 E SurfaceControl: 	at io.devicefarmer.minicap.SimpleServer.start(SimpleServer.kt:41)
04-15 13:43:36.437 13748 13748 E SurfaceControl: 	at io.devicefarmer.minicap.Main$Companion.main(Main.kt:87)
04-15 13:43:36.437 13748 13748 E SurfaceControl: 	at io.devicefarmer.minicap.Main.main(Unknown Source:2)
04-15 13:43:36.437 13748 13748 E SurfaceControl: 	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
04-15 13:43:36.437 13748 13748 E SurfaceControl: 	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:369)
04-15 13:43:36.437 13748 13748 D AndroidRuntime: Shutting down VM
04-15 13:43:36.438 13748 13748 E AndroidRuntime: FATAL EXCEPTION: main
04-15 13:43:36.438 13748 13748 E AndroidRuntime: PID: 13748
04-15 13:43:36.438 13748 13748 E AndroidRuntime: java.lang.Error: java.lang.NoSuchMethodException: android.view.SurfaceControl.createDisplay [class java.lang.String, boolean]
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at io.devicefarmer.minicap.utils.SurfaceControl.createDisplay(SurfaceControl.kt:100)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at io.devicefarmer.minicap.provider.SurfaceProvider.initSurface(SurfaceProvider.kt:87)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at io.devicefarmer.minicap.provider.SurfaceProvider.initSurface(SurfaceProvider.kt:106)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at io.devicefarmer.minicap.provider.SurfaceProvider.onConnection(SurfaceProvider.kt:75)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at io.devicefarmer.minicap.SimpleServer.start(SimpleServer.kt:41)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at io.devicefarmer.minicap.Main$Companion.main(Main.kt:87)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at io.devicefarmer.minicap.Main.main(Unknown Source:2)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:369)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: Caused by: java.lang.NoSuchMethodException: android.view.SurfaceControl.createDisplay [class java.lang.String, boolean]
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at java.lang.Class.getMethod(Class.java:2950)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at java.lang.Class.getMethod(Class.java:2450)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at io.devicefarmer.minicap.utils.SurfaceControl.createDisplay(SurfaceControl.kt:93)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	... 8 more
04-15 13:43:36.438 13748 13748 E AndroidRuntime: Error reporting crash
04-15 13:43:36.438 13748 13748 E AndroidRuntime: java.lang.RuntimeException: Bad file descriptor
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at android.os.BinderProxy.transactNative(Native Method)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at android.os.BinderProxy.transact(BinderProxy.java:586)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at android.os.IServiceManager$Stub$Proxy.checkService(IServiceManager.java:441)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at android.os.ServiceManagerProxy.getService(ServiceManagerNative.java:63)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at android.os.ServiceManager.rawGetService(ServiceManager.java:428)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at android.os.ServiceManager.getService(ServiceManager.java:175)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at android.app.ActivityManager$3.create(ActivityManager.java:5497)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at android.app.ActivityManager$3.create(ActivityManager.java:5494)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at android.util.Singleton.get(Singleton.java:44)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at android.app.ActivityManager.getService(ActivityManager.java:5485)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$KillApplicationHandler.uncaughtException(RuntimeInit.java:170)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1071)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1066)
04-15 13:43:36.438 13748 13748 E AndroidRuntime: 	at java.lang.Thread.dispatchUncaughtException(Thread.java:2306)

Have you tried STF?

Of course yes.

@stoefln
Copy link

stoefln commented Apr 16, 2024

Yup, it's not available anymore.
We fixed it in this commit (by picking taking changes from scrcpy) : repeato-qa@22b1e3f

Sorry, the commit is quite a mess, that's why I didn't send a PR.

I think we should gradually migrate the minicap code to look more like scrcpy. It's just better maintained, and we would save time fixing stuff if we had the same (or more similar) classes and overall structure.

The relevant lines are those:
repeato-qa@22b1e3f#diff-30e1d69f804022c9c0b456b1a514bf3a0d8ab601c430c6a7d9ec32f729b1cf0dR144-R178

@KishanDasani
Copy link

@stoefln @koral-- is there any update on this? is it refactored or merged anywhere?

@varundtsfi
Copy link
Collaborator

Hi @KishanDasani

Actually I have the fix but I am very much familiar with Java now trying to add my code and send a PR.

By this weekend I will send the PR.

@KishanDasani
Copy link

Hi @KishanDasani

Actually I have the fix but I am very much familiar with Java now trying to add my code and send a PR.

By this weekend I will send the PR.

Thank you. will be a big help.

@KishanDasani
Copy link

@varundtsfi

I have cloned fork of repeato-qa, which has fix for this issue, on my mac system and did the build with ndk-build after setting up environment as mentioned in readme. (installed ndk, and make)

that gave me 3 files in libs folder (minicap, minicap-nopie and minicap.so) for arm64-v8a and armeabi-v7a. and I replaced them directly in my node_modules (only minicap & minicap-nopie) files under @devicefarmer/minicap-prebuilt/prebuilt/<ABI>/bin

Screenshot 2024-05-09 at 17 20 18
image 1: generated files inside libs folder via ndk-build command

but now because minicap-prebuilt npm package is not having folders for SDK 31, 32, 33, 34 under lib folder, these files are not taking effect as per the code written in lib/units/device/resources/minicap.js.

Screenshot 2024-05-09 at 17 22 41
image 2: folders for SDK 31 to 34 is not present

is it advisable to create folders for these missing SDKs under @devicefarmer/minicap-prebuilt/prebuilt/<ABI>/lib/android-<SDK> and paste the generated .so (image 1) files in there?

@stoefln
Copy link

stoefln commented May 9, 2024

@KishanDasani the fix is entirely independent from the native binaries. The native binaries are mostly used for old devices AFAIS.
You can just open the project (folder "experimental" in project root) via Android Studio, build an apk and that's it.

@KishanDasani
Copy link

KishanDasani commented May 9, 2024

@KishanDasani the fix is entirely independent from the native binaries. The native binaries are mostly used for old devices AFAIS. You can just open the project (folder "experimental" in project root) via Android Studio, build an apk and that's it.

so directly building an apk from experimental folder and replcing it with apk in "noarch" folder will do the work?

@stoefln
Copy link

stoefln commented May 9, 2024

Not sure where the apk needs to go exactly. We are not using minicap as part of stf.

@KishanDasani
Copy link

I'm using minicap with stf as npm package and facing the issue there itself.

do you suggest to put debug apk, which we'll get by building from experimental folder, into node_modules directly is a good idea?

I'm in need to fix this issue in production environment though.

@varundtsfi
Copy link
Collaborator

@KishanDasani and @stoefln

Actually minicap no more suppted the .so file instead of they have move to the apk approach for screencasting.
#50 (comment)

You just wait till this weekend hope i will give you the fix in apk itself as I have the fix

@KishanDasani
Copy link

@KishanDasani and @stoefln

Actually minicap no more suppted the .so file instead of they have move to the apk approach for screencasting. #50 (comment)

You just wait till this weekend hope i will give you the fix in apk itself as I have the fix

no issues, @varundtsfi
as of now, I built debug apk from experimental folder and was able to get my screen running successfully for pixel devices via stf.
but screenshots are broken, even with other devices which are not pixel and running on lower android versions.

@KishanDasani
Copy link

@KishanDasani and @stoefln
Actually minicap no more suppted the .so file instead of they have move to the apk approach for screencasting. #50 (comment)
You just wait till this weekend hope i will give you the fix in apk itself as I have the fix

no issues, @varundtsfi as of now, I built debug apk from experimental folder and was able to get my screen running successfully for pixel devices via stf. but screenshots are broken, even with other devices which are not pixel and running on lower android versions.

Hi, @varundtsfi
did you get chance to look into this?

@KishanDasani
Copy link

Yup, it's not available anymore. We fixed it in this commit (by picking taking changes from scrcpy) : repeato-qa@22b1e3f

Sorry, the commit is quite a mess, that's why I didn't send a PR.

I think we should gradually migrate the minicap code to look more like scrcpy. It's just better maintained, and we would save time fixing stuff if we had the same (or more similar) classes and overall structure.

The relevant lines are those: repeato-qa@22b1e3f#diff-30e1d69f804022c9c0b456b1a514bf3a0d8ab601c430c6a7d9ec32f729b1cf0dR144-R178

@stoefln while this fixes screen fetching issue for pixel devices, it breaks screenshot for all the devices.
can you please check or help with this?

@KishanDasani
Copy link

I was able to solve the screenshot issue by not taking changes of Main.kt file (changing System.err.printLn to log.info) and logger.kt file (adding printLn with every function).

@varundtsfi
Copy link
Collaborator

@KishanDasani and @stoefln
Actually minicap no more suppted the .so file instead of they have move to the apk approach for screencasting. #50 (comment)
You just wait till this weekend hope i will give you the fix in apk itself as I have the fix

no issues, @varundtsfi as of now, I built debug apk from experimental folder and was able to get my screen running successfully for pixel devices via stf. but screenshots are broken, even with other devices which are not pixel and running on lower android versions.

Hi, @varundtsfi did you get chance to look into this?

Hi Yes,
I have merge the code in KT version on minicap apk
I was busy in some confrences and tomorrow also I will be little busy but yes before end of this week.
I will send a PR Currently I have added the following files which requested by multiple people
(#58)

Sorry for the delay

@KishanDasani
Copy link

@KishanDasani and @stoefln
Actually minicap no more suppted the .so file instead of they have move to the apk approach for screencasting. #50 (comment)
You just wait till this weekend hope i will give you the fix in apk itself as I have the fix

no issues, @varundtsfi as of now, I built debug apk from experimental folder and was able to get my screen running successfully for pixel devices via stf. but screenshots are broken, even with other devices which are not pixel and running on lower android versions.

Hi, @varundtsfi did you get chance to look into this?

Hi Yes, I have merge the code in KT version on minicap apk I was busy in some confrences and tomorrow also I will be little busy but yes before end of this week. I will send a PR Currently I have added the following files which requested by multiple people (#58)

Sorry for the delay

Thank you, @varundtsfi
As of now, I am able to use devices in stf with the minicap apk I built as said earlier.
once you push .apk files for these of the SDKs, will try this solution as well.

@lamadaoudi
Copy link

Hi. Any updates @varundtsfi ?

@varundtsfi
Copy link
Collaborator

varundtsfi commented May 22, 2024

Hi. Any updates @varundtsfi ?

Hi @lamadaoudi and @KishanDasani

Yes I am just sending the PR it's already done.
Screenshot from 2024-05-22 20-31-33

@varundtsfi
Copy link
Collaborator

varundtsfi commented May 27, 2024

Hi @stoefln , @KishanDasani and @lamadaoudi
Now we can close this issue as we have verfied the chagnes. if you want and find any issue you can reopen.

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

5 participants