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

Chinese fonts #112

Closed
coolit opened this issue Aug 11, 2020 · 7 comments
Closed

Chinese fonts #112

coolit opened this issue Aug 11, 2020 · 7 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash

Comments

@coolit
Copy link

coolit commented Aug 11, 2020

I used a custom font (which supports Chinese characters) to build the button example.

If I cargo run from IDE, no error will occur. And if I run the target exe directly from the target-dir, the following error occurred:
thread '' panicked at 'called Option::unwrap() on a None value', crates\bevy_text\src\font_atlas_set.rs:53:20

I tried other Chinese fonts, they all worked fine in most cases. And I guess it was just due to that specific font, which was a home-made one.

So two questions:

  • Why no error will occur if I cargo run it?
  • Why does error also occasionally occur with other Chinese fonts?
@coolit coolit changed the title font_atlas_set error Chinese fonts Aug 11, 2020
@cart
Copy link
Member

cart commented Aug 11, 2020

Why no error will occur if I cargo run it?

This is probably a result of the "root" asset path changing based on the context. If you "cargo run" it will use the cargo workspace as the root folder. if you run a binary, it will use the binary's parent folder as the root. Just copy the asset folder to live next to the binary. (sorry this behavior isn't documented yet)

Why does error also occasionally occur with other Chinese fonts?

If you fix the "asset folder" issue and fonts still don't load, can you send me the fonts so I can test them?

@coolit
Copy link
Author

coolit commented Aug 12, 2020

  • I knew and I already copied the asset folder.
  • The first font attached didn't work most time if I run a binary, only worked occasionally. The second font attached worked most time if I ran a binary, only failed occasionally. The error occasionally occurred for all fonts even when you cargo run it.

wMono.zip
simhei.zip

@coolit
Copy link
Author

coolit commented Aug 12, 2020

Found a new error after running the same binary 3 times. The first 2 times failed. The final one didn't.
01

@cart
Copy link
Member

cart commented Aug 12, 2020

hmm seems like a pretty nasty timing issue. we should fix this asap.

@cart cart added the C-Bug An unexpected or incorrect behavior label Aug 12, 2020
@karroffel karroffel added A-Rendering Drawing game state to the screen P-Crash A sudden unexpected crash labels Aug 12, 2020
@cart
Copy link
Member

cart commented Sep 4, 2020

I just hit this error again on my computer. This is 100% a timing issue where we aren't being forgiving of fonts that are still loading. I think we can fix this pretty easily.

@Gregoor
Copy link
Contributor

Gregoor commented Sep 8, 2020

Also just ran into this when trying to run any of the bevy_rapier (https://github.com/dimforge/bevy_rapier) examples. They don't seem to contain any chinese fonts though. I'm on MacOS and here's a log, if that helps

crash
     Running `/Users/gregor/code/bevy_rapier/target/debug/examples/boxes3`
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_text-0.1.3/src/font_atlas_set.rs:53:42
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1076
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:217
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:526
  11: rust_begin_unwind
             at src/libstd/panicking.rs:437
  12: core::panicking::panic_fmt
  13: core::panicking::panic
  14: core::option::Option<T>::unwrap
             at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/macros/mod.rs:10
  15: bevy_text::font_atlas_set::FontAtlasSet::add_glyphs_to_atlas
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_text-0.1.3/src/font_atlas_set.rs:53
  16: bevy_ui::widget::text::text_system
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ui-0.1.3/src/widget/text.rs:40
  17: core::ops::function::Fn::call
             at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/ops/function.rs:72
  18: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &F>::call_mut
             at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/ops/function.rs:253
  19: <Func as bevy_ecs::system::into_system::IntoQuerySystem<(),(Ra,Rb,Rc,Rd),(A,)>>::system::{{closure}}
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.1.3/src/system/into_system.rs:218
  20: <bevy_ecs::system::into_system::SystemFn<State,F,ThreadLocalF,Init,SetArchetypeAccess> as bevy_ecs::system::system::System>::run
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.1.3/src/system/into_system.rs:61
  21: bevy_ecs::schedule::parallel_executor::ExecutorStage::run_ready_systems::{{closure}}
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.1.3/src/schedule/parallel_executor.rs:313
  22: rayon_core::scope::ScopeFifo::spawn_fifo::{{closure}}::{{closure}}
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/scope/mod.rs:495
  23: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/panic.rs:318
  24: std::panicking::try::do_call
             at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/panicking.rs:348
  25: __rust_try
  26: std::panicking::try
             at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/panicking.rs:325
  27: std::panic::catch_unwind
             at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/panic.rs:394
  28: rayon_core::unwind::halt_unwinding
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/unwind.rs:17
  29: rayon_core::scope::ScopeBase::execute_job_closure
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/scope/mod.rs:561
  30: rayon_core::scope::ScopeBase::execute_job
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/scope/mod.rs:549
  31: rayon_core::scope::ScopeFifo::spawn_fifo::{{closure}}
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/scope/mod.rs:495
  32: <rayon_core::job::HeapJob<BODY> as rayon_core::job::Job>::execute
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/job.rs:167
  33: rayon_core::job::JobRef::execute
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/job.rs:59
  34: <rayon_core::job::JobFifo as rayon_core::job::Job>::execute
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/job.rs:211
  35: rayon_core::job::JobRef::execute
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/job.rs:59
  36: rayon_core::registry::WorkerThread::execute
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/registry.rs:753
  37: rayon_core::registry::WorkerThread::wait_until_cold
  38: rayon_core::registry::WorkerThread::wait_until
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/registry.rs:704
  39: rayon_core::registry::main_loop
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/registry.rs:837
  40: rayon_core::registry::ThreadBuilder::run
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/registry.rs:56
  41: <rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{{closure}}
             at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/registry.rs:101
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
gregor@schmacles bevy_rapier3d % RUST_BACKTRACE=full cargo run --example boxes3
    Finished dev [unoptimized + debuginfo] target(s) in 0.16s
     Running `/Users/gregor/code/bevy_rapier/target/debug/examples/boxes3`
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_text-0.1.3/src/font_atlas_set.rs:53:42
stack backtrace:
   0:        0x105c0ea6e - backtrace::backtrace::libunwind::trace::he0a1acffd944ce3f
                               at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:        0x105c0ea6e - backtrace::backtrace::trace_unsynchronized::ha35c8b21934b5ff7
                               at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:        0x105c0ea6e - std::sys_common::backtrace::_print_fmt::h5e52d5d250a5076b
                               at src/libstd/sys_common/backtrace.rs:78
   3:        0x105c0ea6e - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h24bb64d98a7e25d6
                               at src/libstd/sys_common/backtrace.rs:59
   4:        0x105c3675c - core::fmt::write::h8fdc9cddb01cd8b2
                               at src/libcore/fmt/mod.rs:1076
   5:        0x105c0a8d9 - std::io::Write::write_fmt::hcc3030013983bab6
                               at src/libstd/io/mod.rs:1537
   6:        0x105c10ef5 - std::sys_common::backtrace::_print::hb08b3b51b5188d8a
                               at src/libstd/sys_common/backtrace.rs:62
   7:        0x105c10ef5 - std::sys_common::backtrace::print::h97998656489491bc
                               at src/libstd/sys_common/backtrace.rs:49
   8:        0x105c10ef5 - std::panicking::default_hook::{{closure}}::h95817712c5ff0736
                               at src/libstd/panicking.rs:198
   9:        0x105c10c32 - std::panicking::default_hook::h34e085f4e0b1062d
                               at src/libstd/panicking.rs:217
  10:        0x105c11455 - std::panicking::rust_panic_with_hook::haf571858f996ac45
                               at src/libstd/panicking.rs:526
  11:        0x105c11022 - rust_begin_unwind
                               at src/libstd/panicking.rs:437
  12:        0x105c60fbf - core::panicking::panic_fmt::h11676ba6a846d9f4
  13:        0x105c60f17 - core::panicking::panic::hbac86dffb7f54900
  14:        0x10522840a - core::option::Option<T>::unwrap::h45a94d58408f3223
                               at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/macros/mod.rs:10
  15:        0x105240aa0 - bevy_text::font_atlas_set::FontAtlasSet::add_glyphs_to_atlas::hfee71aea8bbdc2da
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_text-0.1.3/src/font_atlas_set.rs:53
  16:        0x1051a4f26 - bevy_ui::widget::text::text_system::hee9884a99234ad47
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ui-0.1.3/src/widget/text.rs:40
  17:        0x1051b55b5 - core::ops::function::Fn::call::h68e163e8920aac65
                               at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/ops/function.rs:72
  18:        0x10519f4cf - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &F>::call_mut::h7e67e2169481d91b
                               at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/ops/function.rs:253
  19:        0x105193099 - <Func as bevy_ecs::system::into_system::IntoQuerySystem<(),(Ra,Rb,Rc,Rd),(A,)>>::system::{{closure}}::ha54c123d0fea82a1
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.1.3/src/system/into_system.rs:218
  20:        0x105194a2f - <bevy_ecs::system::into_system::SystemFn<State,F,ThreadLocalF,Init,SetArchetypeAccess> as bevy_ecs::system::system::System>::run::h43b803d6e703457f
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.1.3/src/system/into_system.rs:61
  21:        0x10594e104 - bevy_ecs::schedule::parallel_executor::ExecutorStage::run_ready_systems::{{closure}}::ha514536f1769b1cf
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.1.3/src/schedule/parallel_executor.rs:313
  22:        0x105948cb6 - rayon_core::scope::ScopeFifo::spawn_fifo::{{closure}}::{{closure}}::hd102b588f13c142a
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/scope/mod.rs:495
  23:        0x10593f7c1 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h5bbe0641087cb813
                               at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/panic.rs:318
  24:        0x1059505a5 - std::panicking::try::do_call::hfd766bcc34f04d87
                               at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/panicking.rs:348
  25:        0x105951a0d - __rust_try
  26:        0x10594ff21 - std::panicking::try::h844e56aee433fcc1
                               at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/panicking.rs:325
  27:        0x1059401c1 - std::panic::catch_unwind::h36f0d447a12e8dc7
                               at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/panic.rs:394
  28:        0x105951de5 - rayon_core::unwind::halt_unwinding::h4210e8015a7c1d65
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/unwind.rs:17
  29:        0x105948649 - rayon_core::scope::ScopeBase::execute_job_closure::hca852c3a4d670a0e
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/scope/mod.rs:561
  30:        0x105948505 - rayon_core::scope::ScopeBase::execute_job::he24652bbc72fc782
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/scope/mod.rs:549
  31:        0x105948c5d - rayon_core::scope::ScopeFifo::spawn_fifo::{{closure}}::hc389ba130598eebd
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/scope/mod.rs:495
  32:        0x10594adfd - <rayon_core::job::HeapJob<BODY> as rayon_core::job::Job>::execute::h6df9ec3a0e2d6ee9
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/job.rs:167
  33:        0x10596bfc5 - rayon_core::job::JobRef::execute::he69ee7fdb5600d91
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/job.rs:59
  34:        0x10596c0d8 - <rayon_core::job::JobFifo as rayon_core::job::Job>::execute::hffc79fae400276bc
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/job.rs:211
  35:        0x10596bfc5 - rayon_core::job::JobRef::execute::he69ee7fdb5600d91
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/job.rs:59
  36:        0x10597b00d - rayon_core::registry::WorkerThread::execute::he9ee35a325286672
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/registry.rs:753
  37:        0x105c5c0d3 - rayon_core::registry::WorkerThread::wait_until_cold::h1ffcb78eb7f7be69
  38:        0x10597aeb8 - rayon_core::registry::WorkerThread::wait_until::h4d01ec49277caa61
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/registry.rs:704
  39:        0x10597b839 - rayon_core::registry::main_loop::hed775372d374427e
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/registry.rs:837
  40:        0x1059784f0 - rayon_core::registry::ThreadBuilder::run::h469ba02ec51f305c
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/registry.rs:56
  41:        0x1059789b1 - <rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{{closure}}::ha67d549daa85b2b9
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/registry.rs:101
  42:        0x1059a4b11 - std::sys_common::backtrace::__rust_begin_short_backtrace::hbf562527c6818d33
                               at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/sys_common/backtrace.rs:130
  43:        0x1059a2b81 - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::h2b7466fb061a800b
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/sleep/counters.rs:26
  44:        0x105990d91 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h8dd122dde2bdc75d
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/sleep/counters.rs:26
  45:        0x10597cbd5 - std::panicking::try::do_call::ha97fe1675b330111
                               at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/panicking.rs:348
  46:        0x10597ffed - __rust_try
  47:        0x10597c8b1 - std::panicking::try::haef3cfd776c66b94
                               at /Users/gregor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/panicking.rs:325
  48:        0x105991c44 - std::panic::catch_unwind::h8aad26025e78404a
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/sleep/counters.rs:26
  49:        0x1059a26a8 - std::thread::Builder::spawn_unchecked::{{closure}}::he7999492a9e3faca
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/sleep/counters.rs:26
  50:        0x105992521 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h9b54819be7fea7e5
                               at /Users/gregor/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.8.0/src/sleep/counters.rs:26
  51:        0x105c1793d - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::ha37c15d0fd404978
                               at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/liballoc/boxed.rs:1081
  52:        0x105c1793d - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::ha68fe2ca2e0e0dc8
                               at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/liballoc/boxed.rs:1081
  53:        0x105c1793d - std::sys::unix::thread::Thread::new::thread_start::hf8a0ec6cfa81ff3d
                               at src/libstd/sys/unix/thread.rs:87
  54:     0x7fff69792109 - _ZL12preoptimized

@cart
Copy link
Member

cart commented Sep 21, 2020

Fixed by #490

@cart cart closed this as completed Sep 21, 2020
hymm referenced this issue in hymm/bevy Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash
Projects
None yet
Development

No branches or pull requests

4 participants