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

The Meizu phone cannot display the screen. #4143

Closed
Helaer opened this issue Jul 6, 2023 · 34 comments
Closed

The Meizu phone cannot display the screen. #4143

Helaer opened this issue Jul 6, 2023 · 34 comments

Comments

@Helaer
Copy link

Helaer commented Jul 6, 2023

I tried booting with and without audio, but both stuck and couldn't open the window.

C:\Scrcpy>scrcpy -Vdebug
scrcpy 2.1 https://github.com/Genymobile/scrcpy
DEBUG: ADB device found:
DEBUG: --> (usb) Z91QGFWT22376 device meizu_17_Pro
DEBUG: Device serial: Z91QGFWT22376
DEBUG: Using server (portable):C:\Scrcpy\s
crcpy-server
C:\Scrcpy...ped. 60.1 MB/s (58091 bytes in 0.001s)
[server] INFO: Device: [meizu] meizu meizu 17 Pro (Android 11)
[server] DEBUG: Using video encoder: 'OMX.qcom.video.encoder.avc'
DEBUG: Server connected
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
INFO: Renderer: direct3d
DEBUG: Trilinear filtering disabled (not an OpenGL renderer
DEBUG: Using icon (portable): C:\Scrcpy\ico
n.png
DEBUG: Demuxer 'video': starting thread
DEBUG: Demuxer 'audio': starting thread
INFO: Texture: 1080x2336
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] ERROR: Audio capture error
java.io.IOException: Could not read audio: 0
at com.genymobile.scrcpy.AudioEncoder.inputThread(AudioEncoder.java:98)
at com.genymobile.scrcpy.AudioEncoder.lambda$encode$1$com-genymobile-scr
cpy-AudioEncoder(AudioEncoder.java:198)
at com.genymobile.scrcpy.AudioEncoder$$ExternalSyntheticLambda1.run(Unkn
own Source:4)
at java.lang.Thread.run(Thread.java:923)
[server] DEBUG: Audio encoder stopped

C:\Scrcpy>scrcpy --no-audio -Vdebug
scrcpy 2.1 https://github.com/Genymobile/scrcpy
DEBUG: ADB device found:
DEBUG: --> (usb) Z91QGFWT22376 device meizu_17_Pro
DEBUG: Device serial: Z91QGFWT22376
DEBUG: Using server (portable): C:\Scrcpy\s
crcpy-server
C:\Scrcpy...ped. 89.4 MB/s (58091 bytes in 0.001s)
[server] INFO: Device: [meizu] meizu meizu 17 Pro (Android 11)
DEBUG: Server connected
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
[server] DEBUG: Using video encoder: 'OMX.qcom.video.encoder.avc'
INFO: Renderer: direct3d
DEBUG: Trilinear filtering disabled (not an OpenGL renderer
DEBUG: Using icon (portable): C:\Scrcpy\ico
n.png
DEBUG: Demuxer 'video': starting thread
INFO: Texture: 1080x2336

@rom1v
Copy link
Collaborator

rom1v commented Jul 6, 2023

Does it work with scrcpy 2.0 (the previous version)?

Does it work with another video encoder (see scrcpy --list-encoders)?

@Helaer
Copy link
Author

Helaer commented Jul 7, 2023

scrcpy --list-encoders
@rom1v scrcpy2.0 is working fine.

[server] INFO: List of video encoders:
--video-codec=h264 --video-encoder='OMX.qcom.video.encoder.avc'
--video-codec=h264 --video-encoder='OMX.google.h264.encoder'
--video-codec=h265 --video-encoder='OMX.qcom.video.encoder.hevc'
[server] INFO: List of audio encoders:
--audio-codec=aac --audio-encoder='OMX.google.aac.encoder'

DEBUG: Using server (portable): D:\zuomina\scrcpy-win64-v2.0\scrcpy-win64-v2.0\scrcpy-server
D:\zuomina\scrcpy-win64-v2.0\scrcpy-win64-v2.0\scrcpy-serv...file pushed, 0 skipped. 200.5 MB/s (52867 bytes in 0.000s)
[server] INFO: Device: Meizu 16th Plus (Android 8.1.0)
[server] WARN: Audio disabled: it is not supported before Android 11
[server] DEBUG: Audio encoder stopped
DEBUG: Server connected
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
[server] DEBUG: Using encoder: 'OMX.qcom.video.encoder.avc'
INFO: Renderer: direct3d
DEBUG: Trilinear filtering disabled (not an OpenGL renderer)
DEBUG: Using icon (portable): D:\zuomina\scrcpy-win64-v2.0\scrcpy-win64-v2.0\icon.png
DEBUG: Demuxer 'video': starting thread
DEBUG: Demuxer 'audio': starting thread
INFO: Initial texture: 1080x2160
WARN: Demuxer 'audio': stream explicitly disabled by the device

@Helaer
Copy link
Author

Helaer commented Jul 7, 2023

I tested several Meizu phones in succession,scrcpy2.1 version of all Meizu mobile phones can not load the screen normally.

@rom1v
Copy link
Collaborator

rom1v commented Jul 7, 2023

Thank you for your report.

Could you please find out which commit introduced the problem between 2.0 and 2.1? See #4146

@Helaer
Copy link
Author

Helaer commented Jul 7, 2023

Thank you for your report.

Could you please find out which commit introduced the problem between 2.0 and 2.1? See #4146

@rom1v 6ba99a6 This branch works fine, the problem is in the latest branch.

@Helaer
Copy link
Author

Helaer commented Jul 7, 2023

image
image

I noticed that you removed this method in the latest branch.

@rom1v
Copy link
Collaborator

rom1v commented Jul 7, 2023

@Helaer Thank you.

Could you please test which combinaison of mustFillAppInfo, mustFillBaseContext and mustFillAppContext work for Meizu phones?

if (mustFillAppInfo) {
Workarounds.fillAppInfo();
}
if (mustFillBaseContext) {
Workarounds.fillBaseContext();
}
if (mustFillAppContext) {
Workarounds.fillAppContext();
}

@rom1v
Copy link
Collaborator

rom1v commented Jul 7, 2023

6ba99a6 This branch works fine, the problem is in the latest branch.

If 6ba99a6 works, could you please find the exact commit (with git bisect) which breaks?

@Helaer
Copy link
Author

Helaer commented Jul 7, 2023

6ba99a6 This branch works fine, the problem is in the latest branch.

If 6ba99a6 works, could you please find the exact commit (with git bisect) which breaks?

@rom1v I tested all three methods, and none of them worked for Meizu. I don't know if you changed anything other than the split method.

@rom1v
Copy link
Collaborator

rom1v commented Jul 7, 2023

I tested all three methods, and none of them worked for Meizu. I don't know if you changed anything other than the split method.

Even with the 3 enabled at the same time? Or any 2? or any 1? or none? (there are 8 combinations)

Will have to find the offending commit with git bisect 😉

@Helaer
Copy link
Author

Helaer commented Jul 7, 2023

I tested all three methods, and none of them worked for Meizu. I don't know if you changed anything other than the split method.

Even with the 3 enabled at the same time? Or any 2? or any 1? or none? (there are 8 combinations)

Will have to find the offending commit with git bisect 😉

@rom1v Sorry, I may not have forgotten to replace the file, Now I retest this branch (6ba99a6) is also not work properly, Here is the scrcpy2.0 log prompt.

[server] INFO: Device: Meizu 16th Plus (Android 8.1.0)
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.AssertionError: java.lang.NoSuchMethodException: registerDisplayFoldListener [interface android.view.IDisplayFoldListener]
at com.genymobile.scrcpy.wrappers.WindowManager.registerDisplayFoldListener(WindowManager.java:118)
at com.genymobile.scrcpy.Device.(Device.java:102)
at com.genymobile.scrcpy.Server.scrcpy(Server.java:91)
at com.genymobile.scrcpy.Server.main(Server.java:218)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:285)
Caused by: java.lang.NoSuchMethodException: registerDisplayFoldListener [interface android.view.IDisplayFoldListener]
at java.lang.Class.getMethod(Class.java:2068)
at java.lang.Class.getMethod(Class.java:1690)
at com.genymobile.scrcpy.wrappers.WindowManager.registerDisplayFoldListener(WindowManager.java:116)
... 5 more
DEBUG: Interrupting socket
DEBUG: Server disconnected
DEBUG: Server terminated
ERROR: Server connection failed

@rom1v
Copy link
Collaborator

rom1v commented Jul 7, 2023

Oh, you will need to chery-pick c0f3c08.

@Helaer
Copy link
Author

Helaer commented Jul 7, 2023

Oh, you will need to chery-pick c0f3c08.

@rom1v I tested this branch on a branch before (6ba99a6), it can work properly on my meizu phone, What is clear is that this branch (6ba99a6) in the meizu on android version of android 8.1 open not work properly.

@rom1v
Copy link
Collaborator

rom1v commented Jul 7, 2023

What is clear is that this branch (6ba99a6) in the meizu on android version of android 8.1 open not work properly.

Now I retest this branch (6ba99a6) is also not work properly

In fact, you are not testing the correct scrcpy-server, since the exception in the stack trace is related to registerDisplayFoldListener(), which has been added later (after that commit).

@Helaer
Copy link
Author

Helaer commented Jul 7, 2023

What is clear is that this branch (6ba99a6) in the meizu on android version of android 8.1 open not work properly.

Now I retest this branch (6ba99a6) is also not work properly

In fact, you are not testing the correct scrcpy-server, since the exception in the stack trace is related to , which has been added later (after that commit).registerDisplayFoldListener()

I don't know what can be done, but what is clear is that the problem is out on this branch (6ba99a6).

@Helaer
Copy link
Author

Helaer commented Jul 7, 2023

@rom1v Do you have a fix for Meizu? I can test it for you.

@rom1v
Copy link
Collaborator

rom1v commented Jul 7, 2023

but what is clear is that the problem is out on this branch (6ba99a6).

What is the problem/error message observed if you build and run on this commit? It could not be the stacktrace you posted in #4143 (comment) (the code/line numbers do not match).

@Helaer
Copy link
Author

Helaer commented Jul 7, 2023

but what is clear is that the problem is out on this branch (6ba99a6).

What is the problem/error message observed if you build and run on this commit? It could not be the stacktrace you posted in #4143 (comment) (the code/line numbers do not match).

I built on windows using MSYS2 MINGW64 without any errors.I have two Meizu phones, one with Android 8.1 and one with Android 11, and neither of them can use version 2.1 of ScrCPy.

$ ./server/scripts/build-wrapper.sh "server" "server/scrcpy-server" "release"

BUILD SUCCESSFUL in 8s
37 actionable tasks: 37 executed

@rom1v
Copy link
Collaborator

rom1v commented Jul 7, 2023

@Helaer I understand that on your devices, it works on scrcpy v2.0 but not on v2.1.

I just point out that in your tests to find the culprit commit, you said that you built the version from commit 6ba99a6 and that running this version did not work for your Meizu phone.

But you posted this stacktrace:

[server] INFO: Device: Meizu 16th Plus (Android 8.1.0)
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.AssertionError: java.lang.NoSuchMethodException: registerDisplayFoldListener [interface android.view.IDisplayFoldListener]
at com.genymobile.scrcpy.wrappers.WindowManager.registerDisplayFoldListener(WindowManager.java:118)

The code and line numbers do not match commit 6ba99a6, so definitely the scrcpy-server you tested is not the expected one. Therefore, we cannot conclude if 6ba99a6 is ok or not (and what is the real error/problem when the built scrcpy-server matches the commit).

@Helaer
Copy link
Author

Helaer commented Jul 7, 2023

@rom1v

我知道在您的设备上,它适用于 scrcpy v2.0,但不适用于 v2.1。

我只是指出,在您查找罪魁祸首提交的测试中,您您从提交 6ba99a6 构建了版本,并且运行此版本不适用于您的魅族手机。

但是您发布了此堆栈跟踪:

[服务器]信息: 设备: 魅族 16th Plus (Android 8.1.0) [服务器] 错误: 线程线程 [main,5,main] 上的异常 java.lang.AssertionError: java.lang.NoSuchMethodException: registerDisplayFoldListener [interface android.view.IDisplayFoldListener] at com.genymobile.scrcpy.wrappers.WindowManager.registerDisplayFoldListener(WindowManager.java:118)

代码和行号与提交 6ba99a6 不匹配,因此您测试的 scrcpy 服务器肯定不是预期的服务器。因此,我们无法断定 6ba99a6 是否正常(以及当构建的 scrcpy-server 与提交匹配时真正的错误/问题是什么)。

Sorry, limited ability can not help you more, I just posted the cmd display information.

@Helaer
Copy link
Author

Helaer commented Jul 7, 2023

@rom1v Sorry, I deleted all the project files, rebuilt this branch (6ba99a6) and it worked again on my Meizu phone. The problem with 2.1 is that the window cannot be displayed normally, I really don't know what the problem is causing it.

@rom1v
Copy link
Collaborator

rom1v commented Jul 7, 2023

Sorry, I deleted all the project files, rebuilt this branch (6ba99a6) and it worked again on my Meizu phone.

OK thank you for the test :)

The problem with 2.1 is that the window cannot be displayed normally, I really don't know what the problem is causing it.

The problem is between 6ba99a6 and v2.1. If you could try git bisect, it would help:

git bisect start
git bisect good 6ba99a62ff51c0ce209db78a9ed17f1633170027
git bisect bad v2.1
# CHECKPOINT
# it checkouts a version to test
# build it and run to see if it works
ninja -Cx && ./run x
# if it works (the window is opened normally):
git bisect good
# or if it does not work (the problem is the same as v2.1):
git bit bad
# goto CHECKPOINT

@Helaer
Copy link
Author

Helaer commented Jul 9, 2023

Sorry, I deleted all the project files, rebuilt this branch (6ba99a6) and it worked again on my Meizu phone.

OK thank you for the test :)

The problem with 2.1 is that the window cannot be displayed normally, I really don't know what the problem is causing it.

The problem is between 6ba99a6 and v2.1. If you could try git bisect, it would help:

git bisect start
git bisect good 6ba99a62ff51c0ce209db78a9ed17f1633170027
git bisect bad v2.1
# CHECKPOINT
# it checkouts a version to test
# build it and run to see if it works
ninja -Cx && ./run x
# if it works (the window is opened normally):
git bisect good
# or if it does not work (the problem is the same as v2.1):
git bit bad
# goto CHECKPOINT

@rom1v Problem found, branch is located in (feab870), the log is as follows:

mr.zhang@DESKTOP-K371ALP MINGW64 /d/scrcpy ((92483fe...)|BISECTING)
$ git bisect good
Bisecting: 12 revisions left to test after this (roughly 4 steps)
[7d33798] Upgrade FFmpeg build to 6.0-scrcpy-4

mr.zhang@DESKTOP-K371ALP MINGW64 /d/scrcpy ((7d33798...)|BISECTING)
$ git bisect bad
Bisecting: 6 revisions left to test after this (roughly 3 steps)
[be86e14] Factorize record format parsing

mr.zhang@DESKTOP-K371ALP MINGW64 /d/scrcpy ((be86e14...)|BISECTING)
$ git bisect bad
Bisecting: 2 revisions left to test after this (roughly 2 steps)
[feab870] Convert screen encoder to async proce
ssor

mr.zhang@DESKTOP-K371ALP MINGW64 /d/scrcpy ((feab870...)|BISECTING)
$ git bisect bad
Bisecting: 0 revisions left to test after this (roughly 1 step)
[751a365] Add missing @OverRide annotations

mr.zhang@DESKTOP-K371ALP MINGW64 /d/scrcpy ((751a365...)|BISECTING)
$ git bisect good
feab870 is the first bad commit
commit feab870
Author: Romain Vimont rom@rom1v.com
Date: Sun Apr 9 15:17:54 2023 +0200

Convert screen encoder to async processor

Contrary to the other tasks (controller and audio capture/encoding), the
screen encoder was executed synchronously. As a consequence,
scrcpy-server could not terminate until the screen encoder returned.

Convert it to an async processor. This allows to terminate on controller
error, and this paves the way to disable video mirroring.

PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978>

.../java/com/genymobile/scrcpy/AsyncProcessor.java | 11 ++++-
.../java/com/genymobile/scrcpy/AudioEncoder.java | 10 ++++-
.../com/genymobile/scrcpy/AudioRawRecorder.java | 5 ++-
.../java/com/genymobile/scrcpy/Controller.java | 3 +-
.../java/com/genymobile/scrcpy/ScreenEncoder.java | 50 ++++++++++++++++++++--
.../main/java/com/genymobile/scrcpy/Server.java | 46 +++++++++++++++-----
6 files changed, 105 insertions(+), 20 deletions(-)

@Helaer
Copy link
Author

Helaer commented Jul 9, 2023

@rom1v Can you analyze the problem as soon as possible now, and release a repair code, so that I can quickly help you test, I will soon get off work.

@rom1v
Copy link
Collaborator

rom1v commented Jul 9, 2023

Thank you very much. That's unexpected, I will try to understand why.

Just to be absolutely sure, if you checkout feab870 it does not work, but on the previous commit, 751a365, it works, is it correct?

@rom1v
Copy link
Collaborator

rom1v commented Jul 9, 2023

Oh, I think I have an explanation: IIRC the meizu phone requires that the encoder thread has a looper. The commit changing the thread of the video screen encoder broke this assumption.

Calling Looper.prepare() from that thread should fix the problem if I'm correct. Try adding Looper.prepare(); as the very first line of streamScreen() in ScreenEncoder.java (sorry, I'm writing this message from the phone, so I can't make a diff easily).

@Helaer
Copy link
Author

Helaer commented Jul 10, 2023

Thank you very much. That's unexpected, I will try to understand why.

Just to be absolutely sure, if you checkout feab870 it does not work, but on the previous commit, 751a365, it works, is it correct?

@rom1v Yes, (751a365) can work normally.

@Helaer
Copy link
Author

Helaer commented Jul 10, 2023

Oh, I think I have an explanation: IIRC the meizu phone requires that the encoder thread has a looper. The commit changing the thread of the video screen encoder broke this assumption.

Calling from that thread should fix the problem if I'm correct. Try adding as the very first line of in (sorry, I'm writing this message from the phone, so I can't make a diff easily).Looper.prepare()``Looper.prepare();``streamScreen()``ScreenEncoder.java

I don't know what to do, but if you have a fix, I can help you test it.

@yume-chan
Copy link
Contributor

Please test scrcpy-server.zip

diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
index db15d5f3..0559c451 100644
--- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
+++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
@@ -8,6 +8,7 @@ import android.media.MediaCodecInfo;
 import android.media.MediaFormat;
 import android.os.Build;
 import android.os.IBinder;
+import android.os.Looper;
 import android.os.SystemClock;
 import android.view.Surface;

@@ -68,6 +69,8 @@ public class ScreenEncoder implements Device.RotationListener, Device.FoldListen
     }

     private void streamScreen() throws IOException, ConfigurationException {
+        Looper.prepare();
+
         Codec codec = streamer.getCodec();
         MediaCodec mediaCodec = createMediaCodec(codec, encoderName);
         MediaFormat format = createFormat(codec.getMimeType(), videoBitRate, maxFps, codecOptions);

@Helaer
Copy link
Author

Helaer commented Jul 10, 2023

Please test scrcpy-server.zip

diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
index db15d5f3..0559c451 100644
--- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
+++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
@@ -8,6 +8,7 @@ import android.media.MediaCodecInfo;
 import android.media.MediaFormat;
 import android.os.Build;
 import android.os.IBinder;
+import android.os.Looper;
 import android.os.SystemClock;
 import android.view.Surface;

@@ -68,6 +69,8 @@ public class ScreenEncoder implements Device.RotationListener, Device.FoldListen
     }

     private void streamScreen() throws IOException, ConfigurationException {
+        Looper.prepare();
+
         Codec codec = streamer.getCodec();
         MediaCodec mediaCodec = createMediaCodec(codec, encoderName);
         MediaFormat format = createFormat(codec.getMimeType(), videoBitRate, maxFps, codecOptions);

Thank you, this patch is effective, my Meizu phone can work normally.

@Helaer
Copy link
Author

Helaer commented Jul 10, 2023

Oh, I think I have an explanation: IIRC the meizu phone requires that the encoder thread has a looper. The commit changing the thread of the video screen encoder broke this assumption.

Calling Looper.prepare() from that thread should fix the problem if I'm correct. Try adding Looper.prepare(); as the very first line of streamScreen() in ScreenEncoder.java (sorry, I'm writing this message from the phone, so I can't make a diff easily).

@rom1v You are too bull, this method is effective, my Meizu mobile phone can normally use scrcpy2.1 version.

@rom1v
Copy link
Collaborator

rom1v commented Jul 10, 2023

Perfect 👌

Is audio encoding also impacted on v2.1?

scrcpy --no-video

(since your phone runs Android 11, don't forget to switch on and unlock the device before running the command)

@Helaer
Copy link
Author

Helaer commented Jul 12, 2023

Perfect 👌

Is audio encoding also impacted on v2.1?

scrcpy --no-video

(since your phone runs Android 11, don't forget to switch on and unlock the device before running the command)

Audio forwarding works properly.

@rom1v
Copy link
Collaborator

rom1v commented Jul 13, 2023

7e936fa pushed to dev.

Please re-test the current dev branch to be absolutely sure. I might publish a v2.1.1 soon with just bugfixes (this one and some others).

@rom1v rom1v closed this as completed in 7e936fa Jul 14, 2023
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

3 participants