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

Deno.UnsafeWindowSurface panics with x11 #23433

Closed
Tracked by #23563
slydor opened this issue Apr 18, 2024 · 3 comments · Fixed by #24201
Closed
Tracked by #23563

Deno.UnsafeWindowSurface panics with x11 #23433

slydor opened this issue Apr 18, 2024 · 3 comments · Fixed by #24201
Labels
bug Something isn't working correctly webgpu WebGPU API

Comments

@slydor
Copy link

slydor commented Apr 18, 2024

Hi, I wanted to try out the new UnsafeWindowSurface API and encountered an issue:

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 1.42.4
Args: ["deno", "run", "--unstable", "--allow-ffi", "./repro.ts"]

thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.275.0/gotham_state.rs:74:3:
required type alloc::sync::Arc<wgpu_core::global::Global<wgpu_core::identity::IdentityManagerFactory>> is not present in GothamState container
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: deno_core::gotham_state::missing
   3: deno_core::gotham_state::GothamState::borrow
   4: deno_webgpu::byow::op_webgpu_surface_create::op_webgpu_surface_create::v8_fn_ptr
   5: Builtins_CallApiCallbackGeneric
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Using this minimal snippet:

// repro.ts

const x11functions = {
  XOpenDisplay: { parameters: ['usize'], result: 'pointer' },
  XCloseDisplay: { parameters: ['pointer'], result: 'void' },
  XDefaultScreenOfDisplay: { parameters: ['pointer'], result: 'pointer' },
  XMapWindow: { parameters: ['pointer', 'usize'], result: 'void' },
  XPending: { parameters: ['pointer'], result: 'i32' },
  XSelectInput: { parameters: ['pointer', 'usize', 'u64'], result: 'void' },
  XNextEvent: { parameters: ['pointer', 'pointer'], result: 'void' },
  XCreateSimpleWindow: {
    parameters: [
      'pointer',
      'usize',
      'i32',
      'i32',
      'u32',
      'u32',
      'u32',
      'u64',
      'u64'
    ],
    result: 'usize'
  }
} as const

const X11 = Deno.dlopen('libX11.so', x11functions)
const display = X11.symbols.XOpenDisplay(0)
const screen = X11.symbols.XDefaultScreenOfDisplay(display)

// Deno panics here
new Deno.UnsafeWindowSurface('x11', screen, display)

and run with:

RUST_BACKTRACE=1 deno run --unstable --allow-ffi ./repro.ts 

Am I using the API incorrectly or maybe use x11 incorrectly? I want to integrate UnsafeWindowSurface into https://github.com/KnorpelSenf/winding/blob/main/src/x11/mod.ts and the example if winding creates a native window locally.

I'm also very new to this topic, x11 and Deno, so please excuse any obvious errors I might have made.

I use Ubuntu 20.04.

@littledivy
Copy link
Member

This seems like a bug in how WebGPU is initialized.

It should work if you call await navigator.gpu.requestAdapter() before calling UnsafeWindowSurface

@littledivy littledivy added bug Something isn't working correctly webgpu WebGPU API labels Apr 19, 2024
@slydor
Copy link
Author

slydor commented Apr 19, 2024

Yes indeed no panic in that case, thank you. I'll use that work around for now.

@chirsz-ever
Copy link
Contributor

Same with #23298

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly webgpu WebGPU API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants