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

create_surface failed with 'AndroidSurface failed: ERROR_NATIVE_WINDOW_IN_USE_KHR' #3788

Open
lazytiger opened this issue Jul 26, 2022 · 0 comments

Comments

@lazytiger
Copy link

Short info header:

  • GFX version: 0.9
  • OS: Android
  • GPU: Mali-G76 MP10

I am trying to use gfx on the Android platform, but one problem after another, finally, I met the first gfx problem. My codes as the following

 let el = EventLoop::new();
    el.run(move |event, el, control_flow| {
        *control_flow = ControlFlow::Wait;
        match event {
            Event::Resumed => unsafe {
                log::info!("window resumed");
                let window_builder = WindowBuilder::new().with_title("hello");
                let window = ContextBuilder::new()
                    .build_windowed(window_builder, el)
                    .unwrap()
                    .make_current()
                    .unwrap();
                log::info!("windows created");
                let surface_extent = Extent2D {
                    width: 1024,
                    height: 768,
                };
                // The `instance` is an entry point to the graphics API. The `1` in the
                // call is a version number - we don't care about that for now.
                //
                // The `surface` is an abstraction of the OS window we're drawing into.
                // In `gfx`, it also manages the swap chain, which is a chain of
                // multiple images for us to render to. While one is being displayed, we
                // can write to another one - and then swap them, hence the name.
                //
                // The `adapter` represents a physical device. A graphics card for example.
                // The host may have more than one, but below, we just take the first.
                let (instance, surface, adapter) = {
                    let instance =
                        backend::Instance::create(APP_NAME, 1).expect("Backend not supported");
                    let surface = instance
                        .create_surface(window.window())
                        .expect("Failed to create surface for window");

                    let adapter = instance.enumerate_adapters().remove(0);

                    (instance, surface, adapter)
                };
[package]
name = "gars"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["lib", "cdylib"]

[target.'cfg(target_os="android")'.dependencies]
ndk-glue = { version = "0.5", features = ["logger"] }
gfx-backend-vulkan = "0.9"
#gfx-backend-gl = "0.9"

[dependencies]
glutin = { git = "https://github.com/rust-windowing/glutin.git", branch = "android-example" }
log = "0.4"
gfx-hal = "0.9"
byteorder = "1.4"
gfx_core = "0.9"

[target.'cfg(not(target_os="android"))'.dependencies]
chrono = "0.4"
fern = "0.6"
gfx-backend-dx11 = "0.9"
#gfx-backend-gl = "0.9"
shaderc = "0.7"

[package.metadata.android]
package_name = "com.babeltime.gars"
label = "android test"
fullscreen = true
build_targets = ["armv7-linux-androideabi", "aarch64-linux-android"]

[package.metadata.android.application_attributes]
"android:hardwareAccelerated" = "true"

I also tried to use gfx-backend-gl but create_surface also failed with 'BadAlloc'.

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

1 participant