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 simulator hello world triangle GL create_platform_window_surface error #2101

Closed
tachyon-ops opened this issue Oct 21, 2021 · 1 comment · Fixed by #2105
Closed

Android simulator hello world triangle GL create_platform_window_surface error #2101

tachyon-ops opened this issue Oct 21, 2021 · 1 comment · Fixed by #2105
Assignees
Labels
area: correctness We're behaving incorrectly type: bug Something isn't working

Comments

@tachyon-ops
Copy link

tachyon-ops commented Oct 21, 2021

Description
On android, if I run on a physical device, it works. But once I try to use GL to use the simulator I get a fatal error due to create_platform_window_surface error.

Repro steps
I've built my example using WGPU_BACKEND=gl RUST_LOG=trace RUST_BACKTRACE=full cargo apk build

  1. Clone https://github.com/nmpribeiro/ruinx.git with submodules (wgpu is a submodule)
  2. Checkout feature/update_wgpu
  3. run ./android_sim.sh -d

Expected vs observed behavior
Should present the triangle, instead it is fatal failing.

Extra materials
LOG:

10/21 16:03:00: Launching 'app' on Pixel 3a API 30.
...
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
I/RustStdoutStderr: Get instance
D/HostConnection: HostConnection::get() New Host Connection established 0xebc21640, tid 6575
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_3_0 
D/vulkan: searching for layers in '/data/app/~~uNvLQKr2gX4OYJNYaO_21w==/io.github.nmpribeiro.ruinx-mvCe_ff6j7ZBzMWUs6y2tA==/lib/x86'
    searching for layers in '/data/app/~~uNvLQKr2gX4OYJNYaO_21w==/io.github.nmpribeiro.ruinx-mvCe_ff6j7ZBzMWUs6y2tA==/base.apk!/lib/x86'
I/rust-app: wgpu_hal::vulkan::instance: Unable to find extension: VK_EXT_debug_utils
    wgpu_hal::vulkan::instance: Unable to find extension: VK_KHR_get_physical_device_properties2
W/rust-app: wgpu_hal::vulkan::instance: Unable to find layer: VK_LAYER_KHRONOS_validation
D/rust-app: wgpu_hal::gles::egl: Client extensions: [
        "EGL_EXT_client_extensions",
        "EGL_KHR_platform_android",
        "EGL_ANGLE_platform_angle",
        "EGL_ANDROID_GLES_layers",
    ]
I/rust-app: wgpu_hal::gles::egl: Using default platform
I/rust-app: wgpu_hal::gles::egl: Display vendor "Android", version (1, 4)
D/rust-app: wgpu_hal::gles::egl: Display extensions: [
        "EGL_KHR_get_all_proc_addresses",
        "EGL_ANDROID_presentation_time",
        "EGL_KHR_swap_buffers_with_damage",
        "EGL_ANDROID_get_native_client_buffer",
        "EGL_ANDROID_front_buffer_auto_refresh",
        "EGL_ANDROID_get_frame_timestamps",
        "EGL_EXT_surface_SMPTE2086_metadata",
        "EGL_EXT_surface_CTA861_3_metadata",
        "EGL_KHR_image",
        "EGL_KHR_image_base",
        "EGL_KHR_gl_texture_2D_image",
        "EGL_KHR_fence_sync",
        "EGL_KHR_create_context",
        "EGL_ANDROID_image_native_buffer",
        "EGL_KHR_wait_sync",
        "EGL_ANDROID_recordable",
    ]
W/rust-app: wgpu_hal::gles::egl: 	EGL surface: -srgb
I/rust-app: wgpu_hal::gles::egl: 	Trying presentation
W/rust-app: wgpu_hal::gles::egl: EGL says it can present to the window but not natively. This has been confirmed to malfunction on Intel+NV laptops.
I/rust-app: wgpu_hal::gles::egl: 	EGL context: +debug KHR
W/rust-app: wgpu_hal::gles::egl: 	EGL context: -robust access
D/EGL_emulation: eglCreateContext: 0xebc21800: maj 3 min 0 rcv 3
I/RustStdoutStderr: Get surface
I/RustStdoutStderr: Get adapter
D/EGL_emulation: eglMakeCurrent: 0xebc21800: ver 3 0 (tinfo 0xebf71010) (first time)
I/rust-app: wgpu_hal::gles::adapter: Vendor: Google (ATI Technologies Inc.)
    wgpu_hal::gles::adapter: Renderer: Android Emulator OpenGL ES Translator (AMD Radeon Pro 5500M OpenGL Engine)
    wgpu_hal::gles::adapter: Version: OpenGL ES 3.0 (4.1 ATI-4.6.20)
D/rust-app: wgpu_hal::gles::adapter: Extensions: {
        "GL_OES_EGL_image",
        "ANDROID_EMU_CHECKSUM_HELPER_v1",
        "GL_EXT_texture_format_BGRA8888",
        "GL_OES_texture_float",
        "GL_KHR_texture_compression_astc_ldr",
        "ANDROID_EMU_native_sync_v2",
        "GL_OES_vertex_array_object",
        "GL_OES_rgb8_rgba8",
        "ANDROID_EMU_host_side_tracing",
        "ANDROID_EMU_has_shared_slots_host_memory_allocator",
        "ANDROID_EMU_native_sync_v4",
        "GL_OES_depth_texture",
        "ANDROID_EMU_direct_mem",
        "GL_OES_depth32",
        "GL_OES_depth24",
        "GL_EXT_color_buffer_half_float",
        "ANDROID_EMU_sync_buffer_data",
        "GL_EXT_debug_marker",
        "GL_OES_texture_npot",
        "GL_APPLE_texture_format_BGRA8888",
        "ANDROID_EMU_dma_v1",
        "ANDROID_EMU_async_frame_commands",
        "GL_OES_element_index_uint",
        "GL_OES_EGL_image_external",
        "ANDROID_EMU_native_sync_v3",
        "ANDROID_EMU_gles_max_version_3_0",
        "ANDROID_EMU_host_composition_v1",
        "GL_OES_compressed_ETC1_RGB8_texture",
        "GL_EXT_robustness",
        "GL_OES_EGL_sync",
        "ANDROID_EMU_YUV_Cache",
        "ANDROID_EMU_host_composition_v2",
        "GL_EXT_color_buffer_float",
        "GL_OES_compressed_paletted_texture",
        "GL_OES_texture_float_linear",
        "ANDROID_EMU_async_unmap_buffer",
        "GL_OES_EGL_image_external_essl3",
    }
I/rust-app: wgpu_hal::gles::adapter: SL version: OpenGL ES GLSL ES 3.00
I/rust-app: wgpu_core::instance: Adapter GL AdapterInfo { name: "Android Emulator OpenGL ES Translator (AMD Radeon Pro 5500M OpenGL Engine)", vendor: 0, device: 0, device_type: DiscreteGpu, backend: Gl }
I/RustStdoutStderr: using my custom LIMITS!
    Get device and queue
I/RustStdoutStderr: Get shader
D/rust-app: naga::front: Resolving [1] = FunctionArgument(0) : Handle([1])
    naga::front: Resolving [2] = As { expr: [1], kind: Sint, convert: Some(4) } : Value(Scalar { kind: Sint, width: 4 })
    naga::front: Resolving [3] = Constant([1]) : Value(Scalar { kind: Sint, width: 4 })
    naga::front: Resolving [4] = Binary { op: Subtract, left: [2], right: [3] } : Value(Scalar { kind: Sint, width: 4 })
    naga::front: Resolving [5] = As { expr: [4], kind: Float, convert: Some(4) } : Value(Scalar { kind: Float, width: 4 })
    naga::front: Resolving [6] = Constant([2]) : Value(Scalar { kind: Uint, width: 4 })
D/rust-app: naga::front: Resolving [7] = Binary { op: And, left: [1], right: [6] } : Handle([1])
    naga::front: Resolving [8] = As { expr: [7], kind: Sint, convert: Some(4) } : Value(Scalar { kind: Sint, width: 4 })
    naga::front: Resolving [9] = Constant([3]) : Value(Scalar { kind: Sint, width: 4 })
    naga::front: Resolving [10] = Binary { op: Multiply, left: [8], right: [9] } : Value(Scalar { kind: Sint, width: 4 })
    naga::front: Resolving [11] = Constant([1]) : Value(Scalar { kind: Sint, width: 4 })
    naga::front: Resolving [12] = Binary { op: Subtract, left: [10], right: [11] } : Value(Scalar { kind: Sint, width: 4 })
    naga::front: Resolving [13] = As { expr: [12], kind: Float, convert: Some(4) } : Value(Scalar { kind: Float, width: 4 })
D/rust-app: naga::front: Resolving [14] = Constant([4]) : Value(Scalar { kind: Float, width: 4 })
    naga::front: Resolving [15] = Constant([5]) : Value(Scalar { kind: Float, width: 4 })
    naga::front: Resolving [16] = Compose { ty: [2], components: [[5], [13], [14], [15]] } : Handle([2])
    naga::front: Resolving [1] = Constant([5]) : Value(Scalar { kind: Float, width: 4 })
    naga::front: Resolving [2] = Constant([4]) : Value(Scalar { kind: Float, width: 4 })
    naga::front: Resolving [3] = Constant([4]) : Value(Scalar { kind: Float, width: 4 })
    naga::front: Resolving [4] = Constant([5]) : Value(Scalar { kind: Float, width: 4 })
    naga::front: Resolving [5] = Compose { ty: [2], components: [[1], [2], [3], [4]] } : Handle([2])
I/RustStdoutStderr: Get pipeline layout
    Get swap chain format
    Get render pipeline
D/rust-app: wgpu_hal::gles::device: Naga generated shader:
    #version 300 es
    
    precision highp float;
    precision highp int;
    
    
    void main() {
        uint in_vertex_index = uint(gl_VertexID);
        float x = float((int(in_vertex_index) - 1));
        float y = float(((int((in_vertex_index & 1u)) * 2) - 1));
        gl_Position = vec4(x, y, 0.0, 1.0);
        gl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w);
        return;
    }
I/rust-app: wgpu_hal::gles::device: 	Compiled shader NativeShader(5)
D/rust-app: wgpu_hal::gles::device: Naga generated shader:
    #version 300 es
    
    precision highp float;
    precision highp int;
    
    layout(location = 0) out vec4 _fs2p_location0;
    
    void main() {
        _fs2p_location0 = vec4(1.0, 0.0, 0.0, 1.0);
        return;
    }
I/rust-app: wgpu_hal::gles::device: 	Compiled shader NativeShader(6)
I/rust-app: wgpu_hal::gles::device: 	Linked program NativeProgram(4)
    wgpu_core::device: configuring surface with SurfaceConfiguration { usage: RENDER_ATTACHMENT, format: Bgra8Unorm, width: 1080, height: 2220, present_mode: Mailbox }
W/rust-app: wgpu_core::device: Surface does not support present mode: Mailbox, falling back to FIFO
I/RustStdoutStderr: Surface configure!
E/libEGL: eglCreateWindowSurface: native_window_api_connect (win=0xe6587e08) failed (0xffffffea) (already connected to another API?)
    eglCreateWindowSurfaceTmpl:725 error 3003 (EGL_BAD_ALLOC)
W/rust-app: wgpu_hal::gles::egl: Error in create_platform_window_surface: BadAlloc
I/RustStdoutStderr: thread '<unnamed>' panicked at 'Error in Surface::configure: invalid surface', github/wgpu/wgpu/src/backend/direct.rs:204:9
    stack backtrace:
       0: 0xb9fb1b02 - <unknown>
       1: 0xb9fd2638 - <unknown>
       2: 0xb9faf84c - <unknown>
       3: 0xb9fb34c3 - <unknown>
       4: 0xb9fb306a - <unknown>
       5: 0xb9fb3bf9 - <unknown>
       6: 0xb9fb366f - <unknown>
       7: 0xb9fb20a2 - <unknown>
       8: 0xb9fb35d1 - <unknown>
       9: 0xb9662939 - <unknown>
I/RustStdoutStderr:   10: 0xb99d753a - <unknown>
      11: 0xb9841ab3 - <unknown>
      12: 0xb9925057 - <unknown>
      13: 0xb980ca53 - <unknown>
      14: 0xb9809c31 - <unknown>
      15: 0xb9808fd3 - <unknown>
      16: 0xb980cef8 - <unknown>
      17: 0xb98114a2 - <unknown>
      18: 0xb9813448 - <unknown>
      19: 0xb980e498 - <unknown>
      20: 0xb980d7ae - <unknown>
      21: 0xb9809a18 - <unknown>
      22: 0xb9808c8b - <unknown>
      23: 0xb9807e90 - <unknown>
      24: 0xb9663a53 - <unknown>
      25: 0xb9663bc5 - <unknown>
      26: 0xb9f85b91 - <unknown>
      27: 0xb9f7f180 - <unknown>
      28: 0xb9f89d4c - <unknown>
      29: 0xb9f8026c - <unknown>
      30: 0xb9f882e0 - <unknown>
      31: 0xb9f8865f - <unknown>
      32: 0xb9f88248 - <unknown>
      33: 0xb9f8a08c - <unknown>
      34: 0xb9f89896 - <unknown>
      35: 0xb9f8d88c - <unknown>
      36: 0xb9fb5f35 - <unknown>
      37: 0xeb1a9975 - <unknown>
      38: 0xeb13b568 - <unknown>
      39:        0x0 - <unknown>
I/rust-app: wgpu_core::hub: Dropping Global
I/rust-app: wgpu_core::device: Destroying 0 command encoders
W/libEGL: eglTerminate() called w/ 1 objects remaining

Platform
OS: iOS with android studio (I am trying to run in my emulator, check logs for further info)

@kvark kvark added area: correctness We're behaving incorrectly type: bug Something isn't working labels Oct 21, 2021
@kvark kvark self-assigned this Oct 22, 2021
@tachyon-ops
Copy link
Author

tachyon-ops commented Oct 22, 2021

For sake of completeness, I need to report a bit more:

This error is fixed by changing Backend::all() to Backend::GL. But then we get a limits error.
Using the following:

limits: wgpu::Limits {
                        max_texture_dimension_1d: 2048,
                        max_texture_dimension_2d: 2048,
                        max_texture_dimension_3d: 256,
                        max_texture_array_layers: 256,
                        max_bind_groups: 4,
                        max_dynamic_uniform_buffers_per_pipeline_layout: 8,
                        // max_dynamic_storage_buffers_per_pipeline_layout: 4,
                        max_sampled_textures_per_shader_stage: 16,
                        max_samplers_per_shader_stage: 16,
                        // max_storage_buffers_per_shader_stage: 4,
                        // max_storage_textures_per_shader_stage: 4,
                        max_uniform_buffers_per_shader_stage: 12,
                        max_uniform_buffer_binding_size: 16384,
                        // max_storage_buffer_binding_size: 128 << 20,
                        max_vertex_buffers: 8,
                        max_vertex_attributes: 16,
                        // max_vertex_buffer_array_stride: 2048,
                        max_push_constant_size: 0,
                        min_uniform_buffer_offset_alignment: 256,
                        min_storage_buffer_offset_alignment: 256,
                        // These?
                        max_storage_buffers_per_shader_stage: 0,
                        max_storage_textures_per_shader_stage: 0,
                        max_dynamic_storage_buffers_per_pipeline_layout: 0,
                        max_storage_buffer_binding_size: 0,
                        max_vertex_buffer_array_stride: 255,
                    },

Lets us go further into the execution. Up until we bump into

E/libEGL: processAttributes:539 error 3004 (EGL_BAD_ATTRIBUTE)
E/libEGL: error invalid colorspace: -1

With the previously mentioned PR #2105 from @kvark I could then build and execute the triangle example in my android simulator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: correctness We're behaving incorrectly type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants