Blender_bevy_components_workflow icon indicating copy to clipboard operation
Blender_bevy_components_workflow copied to clipboard

Panic when Bevy app with Blenvy is packaged as a macOS `.app`

Open rparrett opened this issue 1 year ago • 2 comments

Noticed this during Bevy Jam 5 where the native mac builds of a few separate games utilizing blenvy failed to launch in a particular way.

https://phlimy.itch.io/way-of-the-sand └ https://github.com/Azorlogh/Bevy-Jam-5/blob/main/Cargo.toml

https://chrisbiscardi.itch.io/wash-cycle └ https://github.com/ChristopherBiscardi/bevy-jam-5/blob/main/Cargo.toml

This behavior depends on how the app is launched:

method result
open way_of_the_sand.app or double click icon app "opens" but closes before window is created
cd way_of_the_sand.app/Contents/MacOS; ./way_of_the_sand works fine
open way_of_the_sand.app/Contents/MacOS/way_of_the_sand terminal opens with blenvy panic (see below)

The panic:

thread 'main' panicked at /Users/runner/.cargo/git/checkouts/blenvy-b36e3bfafcd31d12/aff11cc/crates/blenvy/src/registry/export_types.rs:17:51:
should have created schema file: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `blenvy::registry::export_types::export_types`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!

rparrett avatar Aug 03 '24 16:08 rparrett

It was suggested that setting export_registry to false for release builds is "proper" and also works around this issue, so this might be considered "user error."

I'm not familiar withBlenvy, but a quick glance around the docs and examples didn't turn up anything related, so at the very least this seems like a documentation issue.

However, maybe export_registry should not be the default behavior, or should be behind a feature flag or something? It looks like there's also some code to prevent registry export from happening on Wasm where it also can't work.

rparrett avatar Aug 03 '24 19:08 rparrett

It does seem like the actual underlying issue is something like "AssetRoot somehow does not point to the right place when launching on macOS." or "The current directory isn't what we think it is when launching on macOS."

It looks like Blenvy is just snagging the configured relative path from AssetPlugin, but I believe the proper thing to do would be to use FileAssetReader::get_base_path(). At least, that's what this bevy example does.

rparrett avatar Aug 03 '24 19:08 rparrett