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

Samples don't run on Windows 10 due to COM initialization conflict #4492

Closed
robmikh opened this issue Apr 16, 2022 · 4 comments
Closed

Samples don't run on Windows 10 due to COM initialization conflict #4492

robmikh opened this issue Apr 16, 2022 · 4 comments
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled

Comments

@robmikh
Copy link

robmikh commented Apr 16, 2022

Bevy version

I'm seeing this on 0.7 with commit 83c6ffb

Operating system & version

Windows 10 19043.1645

What you did

I tried a few examples:

  • gltf_skinned_mesh
  • breakout
  • scene

What you expected to happen

Sample runs and does not panic.

What actually happened

All samples that I've run panic when cpal tries to initialize COM with a multithreaded apartment on a thread that is assigned to a single threaded apartment (done by winit):

Z:\cool\path\bevy>cargo run --example scene
   Compiling bevy v0.7.0 (Z:\cool\path\bevy)
    Finished dev [unoptimized + debuginfo] target(s) in 4.92s
     Running `target\debug\examples\scene.exe`
2022-04-15T18:51:41.537468Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 2070 SUPER", vendor: 4318, device: 7812, device_type: DiscreteGpu, backend: Vulkan }
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: -2147417850, kind: Uncategorized, message: "Cannot change thread mode after it is set." }', Z:\cool\pathi\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\cpal-0.13.1\src\host\wasapi\com.rs:13:77
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\examples\scene.exe` (exit code: 101)

Additional information

It looks like the drag and drop support in winit initializes COM with a single threaded apartment, and then later cpal on the same thread tries to initialize COM with a different apartment. The UI thread probably should be STA.

@robmikh robmikh added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 16, 2022
@mockersf
Copy link
Member

mockersf commented Apr 16, 2022

Related to #3772

What version of cpal do you have in your dependencies (in the Cargo.lock file)?

@robmikh
Copy link
Author

robmikh commented Apr 16, 2022

[[package]]
name = "cpal"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05631e2089dfa5d3b6ea1cfbbfd092e2ee5deeb69698911bc976b28b746d3657"
dependencies = [
 "alsa",
 "core-foundation-sys 0.6.2",
 "coreaudio-rs",
 "jni 0.17.0",
 "js-sys",
 "lazy_static",
 "libc",
 "mach 0.3.2",
 "ndk 0.2.1",
 "ndk-glue 0.2.1",
 "nix 0.15.0",
 "oboe",
 "parking_lot",
 "stdweb 0.1.3",
 "thiserror",
 "wasm-bindgen",
 "web-sys",
 "winapi",
]

@mockersf
Copy link
Member

Version 0.13.1 is 1.5 years old and has an issue, could you run cargo update and check that it's at least the 0.13.4, then rerun the examples?

@robmikh
Copy link
Author

robmikh commented Apr 16, 2022

That seems to work! Sorry about that, despite my time with Rust that's the first time a stale lock file bit me.

@robmikh robmikh closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

2 participants