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

Vulkan on Android: the frame isn't updating (ONLY THE FIRST FRAME IS RENDERED) #3242

Open
MohammedKHC opened this issue Jan 23, 2024 · 18 comments

Comments

@MohammedKHC
Copy link

MohammedKHC commented Jan 23, 2024

Describe the bug
It seems like that only the first frame is rendered, but the game loop don't stop, please note that when using Opengl es every thing is working fine.
Please note that vulkan on Linux works fine the problem is on Android

To Reproduce
using https://github.com/Nodrev/bgfx-android-activity for android running
modify samples to use Vulkan backend;
choose the cube sample
you should notice that the cubes doesn't move

Expected behavior
Just work like opengl es.

MORE Context*
My device uses adreno and snap dragon and it's arm64
and i think maybe it has something with #2975

@bkaradzic
Copy link
Owner

using https://github.com/Nodrev/bgfx-android-activity for android running

I'm not going to investigate other repos. Repro has to be inside bgfx repo.

@MohammedKHC
Copy link
Author

Sorry but I really don't understand how to do that, bgfx repo don't have java files for Android, so I can't made something based 100% on bgfx repo, but you don't need to change the native cpp code,
https://github.com/Nodrev/bgfx-android-activity
Is just building bgfx and then link it with MainActivity please take a look at https://github.com/Nodrev/bgfx-android-activity

@truedat101
Copy link

@MohammedKHC I'll take a look on my android device. I am curious myself about the platform support. Is there any newer version of this kind of project? It's unfortunate but this particular repo is 8 years old and only a single pull request to fix support for arm64. Since then Android has moved on. I checked the forks and nothing else.

I found this: https://github.com/LightSun/bgfx-android

about four years old.

Will update. Noting to debug, it's worth putting some logs from your application that reflect the state of the bgfx layer or checkpoints in your own render loop. I agree, one would expect spinning cubes to spin.

Also, you are saying GLES works fine on Android?

@MohammedKHC
Copy link
Author

Hi @truedat101, First sorry for the late response. I wasn't aware of the message..
At the moment I can't send logs, but there wasn't anything special, maybe just try to compile bgfx for Android and use vulkan and tell me if it works?
And yeah GLES works great.

@GEMISIS
Copy link

GEMISIS commented Sep 22, 2024

Checking in on this, seems like there is an issue with Vulkan specifically not rendering properly. Using OpenGL ES on Android everything works fine, but the moment that I switch to Vulkan is just stops rendering after the first frame.

@truedat101 have you had time to look into this? You should be able to just load up the examples provided and see it pretty quickly.

@truedat101
Copy link

Checking in on this, seems like there is an issue with Vulkan specifically not rendering properly. Using OpenGL ES on Android everything works fine, but the moment that I switch to Vulkan is just stops rendering after the first frame.

@truedat101 have you had time to look into this? You should be able to just load up the examples provided and see it pretty quickly.

I lost track of this thread. Let me see, I have a decent device to test test with. WIll kick the tires on this.

@truedat101
Copy link

Checking in on this, seems like there is an issue with Vulkan specifically not rendering properly. Using OpenGL ES on Android everything works fine, but the moment that I switch to Vulkan is just stops rendering after the first frame.

@truedat101 have you had time to look into this? You should be able to just load up the examples provided and see it pretty quickly.

Is there some different semi-modern supported repository for Android/BGFX activity/example applications? In the repo for bgfx we only have the library builds, but the notion of running the executable doesn't make sense unless this has been converted into a native activity somehow. I tried the other repo I referenced is ancient by 4 years, and doesn't build (not a bgfx issue, purely the always moving target of android/gradle). I'm willing to dig into this further but I'd like to start from a solid reference point. I did my build of the android versions of the bgfx library.

@GEMISIS
Copy link

GEMISIS commented Sep 28, 2024

Is there some different semi-modern supported repository for Android/BGFX activity/example applications?

I've been working on my own private repo for this on a VR game engine on Quest I'm building, but let me get a public repo sample you can use for this to make things easier.

@truedat101
Copy link

@GEMISIS what VK driver version is available in your target environment on Quest?

@GEMISIS
Copy link

GEMISIS commented Sep 28, 2024

Not sure, is there an easy way to check? Doesn't seem to be on the debug screen so far as I can tell.

f6531e9c114645bd839a5c2b5b6c229a

(I'm not super familiar with the internals of Vulkan, more OpenGL, so still ramping up on this)

@truedat101
Copy link

There's an api call you can make to get at the details of the VK driver version. Let me figure out how I would do that on android/quest

@truedat101
Copy link

The answer isn't obvious. I looked through the MetaSDK stuff for OpenXR (I assume you are using that?) but I only see a reference to khronos/GL. However, we can assume it's possible to get at the regular android APIs and pull this information: https://developer.android.com/ndk/guides/graphics/getting-started

(a bunch of points there if you scroll down to the vulkan api things). I assume one can get the api version, and then dig into whether there are issues in terms of bugs filed in the driver version. I don't know how Quest is handling it's API updates since this is a driver thing in the OS.

@truedat101
Copy link

I'll get my rig up to date and try to build against the quest xr samples to see if I can figure out the vulkan integration available. But in the meantime @GEMISIS if you have a good bgfx wrapper project you can share for Android, I'd like to start with that and test on some different devices.

@truedat101
Copy link

unknown_003

@GEMISIS it looks like from your screenshot it's VK driver 1.128.8775 (it's a bit blurry, it actually doesn't make sense ... so I am not sure if that's really the vulkan driver or not). If you can publish some source for your sample I can try it on my Quest and figure out the details and get it to dump some different information).

@GEMISIS
Copy link

GEMISIS commented Oct 2, 2024

I think that's the version of BGFX that was built actually, as I noticed that was there in both the OpenGL ES and Vulkan versions.

Working on the Android version, but did not have as much time this past weekend as I thought I would. :/

@bkaradzic
Copy link
Owner

That's bgfx version... Driver version is in log...

@LittleCodingFox
Copy link
Contributor

I also have this issue, please let me know if I can help!

In my case it seems to happen only on landscape, on portrait it renders properly. As soon as I rotate to landscape, it breaks again!

@mcourteaux
Copy link
Contributor

This is most likely related to swapchain invalidation and not having a new one being created. It's a statebug in bgfx. Aurelius reported something similar on Discord. We have @GhoulDaggers saying this on Discord:

Really, there's two different bugs at play here.
One is a bug where on entering fullscreen, I get a size change event of the correct size, BGFX creates a new swap chain, but then somehow that new swap chain gets invalidated - and because it was already at the right size, there's no further size change events and it never creates a new swap chain.

The second bug is that sometimes SDL size change events lag behind the actual window size reported by the surface capabilities query, and in that case the render area can be bigger than the swapchain and crash.

Unfortunately, having Discord next to Github causes some important information to be hidden behind an inconvenient Discord search and a login screen.

I'm now reliably experiencing having only the first frame being rendered on Vulkan, until I resize the window, and I'll probably tackle this issue this week. The issue has reached high-priority on my todo list.

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

6 participants