PistonDevelopers / conrod

An easy-to-use, 2D GUI library written entirely in Rust.
Other
3.35k stars 296 forks source link

Need help figuring out failure in android with conrod_wgpu #1435

Closed tachyon-ops closed 2 years ago

tachyon-ops commented 3 years ago

Hi,

I am trying conrod_wgpu GUI example in android and am having a mysterious error.

A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 24469 (iro.rust_jsx_ui), pid 24269 (iro.rust_jsx_ui)

I added log::info! to all calls I am doing while setting up the renderer and figured that the program seems to be exiting when trying

        log::info!("Get renderer");
        let renderer = conrod_wgpu::Renderer::new(&device, MSAA_SAMPLES, swapchain_format);

Last output is the following:

I/rust-app: graphics::state: Get renderer
I/rust-app: naga::front::spv: Generated by 524296 version 10000
D/rust-app: naga::front::spv:   Capability [2]

...

E/rust-app: wgpu_core::validation: Unexpected varying type: Array { base: [1], size: Constant([5]), stride: 4 }
    wgpu_core::validation: Unexpected varying type: Array { base: [1], size: Constant([5]), stride: 4 }

...

I/rust-app: naga::front::spv: Patching...
D/rust-app: naga::valid::interface: var GlobalVariable { name: Some("text_texture"), class: Handle, binding: Some(ResourceBinding { group: 0, binding: 0 }), ty: [4], init: None, storage_access: (empty) }
    naga::valid::interface: var GlobalVariable { name: Some("image_sampler"), class: Handle, binding: Some(ResourceBinding { group: 0, binding: 1 }), ty: [5], init: None, storage_access: (empty) }
    naga::valid::interface: var GlobalVariable { name: Some("v_uv"), class: Private, binding: None, ty: [6], init: None, storage_access: (empty) }
    naga::valid::interface: var GlobalVariable { name: Some("image_texture"), class: Handle, binding: Some(ResourceBinding { group: 0, binding: 2 }), ty: [4], init: None, storage_access: (empty) }
    naga::valid::interface: var GlobalVariable { name: Some("v_mode"), class: Private, binding: None, ty: [9], init: None, storage_access: (empty) }
    naga::valid::interface: var GlobalVariable { name: Some("Target0"), class: Private, binding: None, ty: [8], init: None, storage_access: (empty) }
    naga::valid::interface: var GlobalVariable { name: Some("v_color"), class: Private, binding: None, ty: [8], init: None, storage_access: (empty) }
D/rust-app: naga::valid::function: var LocalVariable { name: Some("text_alpha"), ty: [1], init: None }
    naga::valid::function: var LocalVariable { name: Some("image_color"), ty: [8], init: None }
I/rust-app: wgpu_core::device: Created texture Valid((0, 1, Vulkan)) with TextureDescriptor { label: Some("conrod_wgpu_glyph_cache_texture"), size: Extent3d { width: 1024, height: 1024, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: D2, format: R8Unorm, usage: COPY_DST | SAMPLED }
I/rust-app: wgpu_core::device: Created texture Valid((1, 1, Vulkan)) with TextureDescriptor { label: Some("conrod_wgpu_image_texture"), size: Extent3d { width: 64, height: 64, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: D2, format: R8Unorm, usage: SAMPLED }
D/rust-app: gfx_backend_vulkan::device: create_graphics_pipeline GraphicsPipelineDesc { label: Some("conrod_render_pipeline_descriptor"), primitive_assembler: Vertex { buffers: [VertexBufferDesc { binding: 0, stride: 36, rate: Vertex }], attributes: [AttributeDesc { location: 0, binding: 0, element: Element { format: Rg32Sfloat, offset: 0 } }, AttributeDesc { location: 1, binding: 0, element: Element { format: Rg32Sfloat, offset: 8 } }, AttributeDesc { location: 2, binding: 0, element: Element { format: Rgba32Sfloat, offset: 16 } }, AttributeDesc { location: 3, binding: 0, element: Element { format: R32Uint, offset: 32 } }], input_assembler: InputAssemblerDesc { primitive: TriangleList, with_adjacency: false, restart_index: None }, vertex: EntryPoint { entry: "main", module: ShaderModule { raw: 0x7dd1ca1f50 }, specialization: Specialization { constants: [], data: [] } }, tessellation: None, geometry: None }, rasterizer: Rasterizer { polygon_mode: Fill, cull_face: NONE, front_face: CounterClockwise, depth_clamping: false, depth_bias: None, conservative: false, line_width: Static(1.0) }, fragment: Some(EntryPoint { entry: "main", module: ShaderModule { raw: 0x7dd1ca1f98 }, specialization: Specialization { constants: [], data: [] } }), blender: BlendDesc { logic_op: None, targets: [ColorBlendDesc { mask: RED | GREEN | BLUE | ALPHA | COLOR | ALL, blend: Some(BlendState { color: Add { src: SrcAlpha, dst: OneMinusSrcAlpha }, alpha: Add { src: One, dst: OneMinusSrcAlpha } }) }] }, depth_stencil: DepthStencilDesc { depth: None, depth_bounds: false, stencil: None }, multisampling: Some(Multisampling { rasterization_samples: 4, sample_shading: None, sample_mask: 18446744073709551615, alpha_coverage: false, alpha_to_one: false }), baked_states: BakedStates { viewport: None, scissor: None, blend_constants: None, depth_bounds: None }, layout: PipelineLayout { raw: 0x7de865fc08 }, subpass: Subpass { index: 0, main_pass: RenderPass { raw: 0x7dd1cb0f18, attachment_count: 1 } }, flags: (empty), parent: None }
A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 24469 (iro.rust_jsx_ui), pid 24269 (iro.rust_jsx_ui)

Can anyone help me figure/debug this out?

Versions:

wgpu = "0.9"
winit = "0.25.0"
conrod = "0.62.1"
conrod_core = "0.74.0"
conrod_wgpu = "0.74.0"
conrod_winit = "0.74.0"
image = "0.23"
mitchmindtree commented 3 years ago

Hey @nmpribeiro, I'd recommend trying to get one of the wgpu examples running first (if you haven't already) and then if those succeed, try and spot any differences between those and the all_winit_wgpu example that might be causing issues.

tachyon-ops commented 3 years ago

@mitchmindtree wgpu example triangle (I tried the hello-triangle in android so far) works fine. I am going through conrad_core and conrad backend wgpu to try to spot exactly what's causing my fatal error with all_winit_wgpu.

tachyon-ops commented 3 years ago

I have updated to wgpu v0.10 and it seems to have more meaningful errors.

If I try to force GL on android:

W/rust-app: wgpu_core::instance: Missing downlevel flags: READ_ONLY_DEPTH_STENCIL | VERTEX_STORAGE
    The underlying API or device in use does not support enough features to be a fully compliant implementation of WebGPU. A subset of the features can still be used. If you are running this program on native and not in a browser and wish to limit the features you use to the supported subset, call Adapter::downlevel_properties or Device::downlevel_properties to get a listing of the features the current platform supports.
I/rust-app: wgpu_core::instance: DownlevelCapabilities {
        flags: COMPUTE_SHADERS | FRAGMENT_WRITABLE_STORAGE | INDIRECT_EXECUTION | BASE_VERTEX | DEVICE_LOCAL_IMAGE_COPIES | NON_POWER_OF_TWO_MIPMAPPED_TEXTURES | CUBE_ARRAY_TEXTURES | COMPARISON_SAMPLERS | INDEPENDENT_BLENDING,
        limits: DownlevelLimits,
        shader_model: Sm5,
    }
E/rust-app: wgpu::backend::direct: Error in Adapter::request_device: Limit 'max_texture_array_layers' value 2048 is better than allowed 256
I/RustStdoutStderr: thread '<unnamed>' panicked at 'Failed to create device: RequestDeviceError', libs/graphics/src/state.rs:90:14

If I use .all() backends:

   graphics::state: Device and Queue!
W/rust-app: wgpu_hal::vulkan::adapter: Missing extensions: ["VK_EXT_sampler_filter_minmax", "VK_KHR_timeline_semaphore"]
D/rust-app: wgpu_hal::vulkan::adapter: Supported extensions: ["VK_KHR_swapchain"]
I/rust-app: wgpu_hal::vulkan::adapter: Private capabilities: PrivateCapabilities { flip_y_requires_shift: true, imageless_framebuffers: false, image_view_usage: true, timeline_semaphores: false, texture_d24: true, texture_d24_s8: true, can_present: true, non_coherent_map_mask: 63 }
E/rust-app: wgpu::backend::direct: Error in Adapter::request_device: Limit 'max_texture_array_layers' value 2048 is better than allowed 256
I/RustStdoutStderr: thread '<unnamed>' panicked at 'Failed to create device: RequestDeviceError', libs/graphics/src/state.rs:87:14

I will research a bit more what these logs mean, but it seems Concord is trying to use capabilities that my testing android device doesn't have.

tachyon-ops commented 3 years ago

@mitchmindtree would you agree this is wgpu related?

kvark commented 3 years ago

Could conrod request max_texture_array_layers value of 256 in the limits instead of the default? We are going to fix the default as well, it matches a recent change in the spec.

tachyon-ops commented 3 years ago

FYI, I looked into @kvark's PR and decided to use his repo/branch in my cargo. It turns out that it runs perfectly in Android.

tachyon-ops commented 2 years ago

I'll wait for conrod to update to current wgpu.