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

java.lang.NullPointerException: getSurface(...) must not be null #1603

Open
orzlenmo opened this issue Oct 13, 2024 · 16 comments
Open

java.lang.NullPointerException: getSurface(...) must not be null #1603

orzlenmo opened this issue Oct 13, 2024 · 16 comments

Comments

@orzlenmo
Copy link

When I use GenericFromFile and push local files, I get
java.lang.NullPointerException: getSurface(...) must not be null
I can confirm that I have implemented the method according to the steps in the document,
surfaceView = OpenGlView(context!!)
bindingFloatWindow?.frameSurfaceView?.addView(surfaceView)
genericFromFile = GenericFromFile(openGlView, this, this, this)
It sometimes works, but sometimes it doesn't, and the above error will appear

微信截图_20241013114136

@pedroSG94
Copy link
Owner

pedroSG94 commented Oct 13, 2024

Hello,

Are you doing the startStream after the preview is inflated like in the example? (Using the onSurfaceChanged callback)

Can you share the code where you are doing startStream?

@orzlenmo
Copy link
Author

微信截图_20241013141331

I added a callback but did not do anything. Because my OpenGlView preview interface is on a float window, when I call startstream, the above error is reported directly. Here is the startStream method

微信截图_20241013141744

@pedroSG94
Copy link
Owner

No matter if you are in a float window. You need wait until that callback is called or the surface will be null or invalid.
You can try add a delay to start stream but it is not a secure way to do it

@orzlenmo
Copy link
Author

I can confirm that my startStream event is executed after surfaceChanged:Surface(name=null)/@0xf77b5a8 has been executed and has a value.
Does it have anything to do with the activity where the float is located?

@pedroSG94
Copy link
Owner

I'm not sure about it but that surface is not ready for some reason. Maybe the surface is created, destroyed and re created.
You can check if the surface if ready using this:

surfaceView.holder.surface.isValid

Also, remember that if your preview was detroyed and you need use a different preview you need change the preview:

//go to background, no preview available
genericFromFile.replaceView(context)
//the preview object changed, replace preview with the new view
genericFromFile.replaceView(openglView)

I can help you more if you are able to share a full code example.

@orzlenmo
Copy link
Author

This is the log I printed. Can you help me analyze it? Thanks to the author
微信截图_20241013151959

@orzlenmo
Copy link
Author

This is the status judgment when the push starts, showing that it is ready
微信截图_20241013152515

@pedroSG94
Copy link
Owner

I will need a full code example to reproduce the error. Can you share me a minimal code example?
You can share it using email if you want:
[email protected]

@orzlenmo
Copy link
Author

It's not that I don't want to post it, it's that my apk is hooked through xposed. This OpenGlView uses the acitivity environment intercepted by the host app, and then a floating window pops up on it. It has been working fine before, but suddenly the host app has been updated. I used your library to push the stream. All the codes are normal, but this problem occurred when I started pushing the stream. So I want to ask you whether it is related to the opengl environment of the app used.

@pedroSG94
Copy link
Owner

I did a fix for it:
#1604
Try with this commit:

  implementation 'com.github.pedroSG94.RootEncoder:library:fix~opengl-start-SNAPSHOT'

@orzlenmo
Copy link
Author

我对此进行了修复: #1604 尝试使用此提交:

  implementation 'com.github.pedroSG94.RootEncoder:library:fix~opengl-start-SNAPSHOT'

I used this version but it still doesn't work. The following two pictures are new errors. Later, I no longer used the previous host activity. I changed an activity to display the OpenGlView on the floating window. Finally, it will not crash. I don't know why some phones crash on which activity. But I really appreciate your answer.
微信截图_20241014152319
微信截图_20241014152328

@pedroSG94
Copy link
Owner

Hello,

Thank you for the report. It is interesting, the library is not able to get shaders resources.
Please, help me to solve the error since I'm not able to reproduce it. I added a new commit that could resolve this error:

  implementation 'com.github.pedroSG94.RootEncoder:library:f0b9aa3fcb'

@orzlenmo
Copy link
Author

Same error as before
微信截图_20241014174355

@pedroSG94
Copy link
Owner

Do you still have resources not found error like before?

@pedroSG94 pedroSG94 added the bug label Oct 14, 2024
@orzlenmo
Copy link
Author

I used it for nearly a year without any problems. Recently, the host app of the xposed hook seemed to have been hot-updated, which started to cause this problem on some models. After I changed the activity, it became normal. So I suggest you ignore this problem, because it is indeed a problem that only occurs with unconventional apps.

@pedroSG94
Copy link
Owner

Hello,

I will ignore this issue until someone find a way to share a code example to reproduce the error.
Marked as help wanted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants