bevyengine / bevyengine/bevy

bevy_render infinite viewport camera panic

Open
#10,216 6 comments 1 reaction 0 assignees View on GitHub
A-Rendering C-Bug I-Crash
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version
0.11.3 installed via Cargo, features - dynamic_linking, bevy_winit
(reproduced on 0.12 as well, see comments)
rustc 1.73.0 (cc66ad468 2023-10-03)

## What you did

Toggling bevy_pls_editor editor via "e" key press.

## What went wrong

It seems like activating a different camera by the editor via is_active causes a panic for some reason.
Probably because viewport camera has infite value for a frame.
Perhaps add some kind of safety instead if viewport values are invalid (or don't render at all / skip it)?

## Stacktrace
```ignore
thread 'Compute Task Pool (13)' panicked at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\core\src\ops\arith.rs:109:1:
attempt to add with overflow
stack backtrace:
0: 0x7ffd719f738a - ::fmt::h90c22c4185b55f04
1: 0x7ffd71a2bb5b - core::fmt::write::h8a7f6edbcadee319
2: 0x7ffd719ecc51 - ::fmt::h0ee392ef0f96e369
3: 0x7ffd719f710a - std::sys_common::backtrace::lock::h134eeaadb35136bd
4: 0x7ffd719fa8ca - std::panicking::default_hook::h81d7caaa8c7a40b4
5: 0x7ffd719fa538 - std::panicking::default_hook::h81d7caaa8c7a40b4
6: 0x7ffd719fb03e - std::panicking::rust_panic_with_hook::h8ac326f3b5470b08
7: 0x7ffd719faeea - ::get::h353ca2f9698f73b3
8: 0x7ffd719f8049 - ::fmt::h90c22c4185b55f04
9: 0x7ffd719fac30 - rust_begin_unwind
10: 0x7ffd71a60d85 - core::panicking::panic_fmt::hb3ce2a19a4187054
11: 0x7ffd71a60e32 - core::panicking::panic::h5206d844b81664c1
12: 0x7ffd6634cc54 - bevy_render::camera::camera::extract_cameras
at C:\Users\UserName\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_render-0.11.3\src\camera\camera.rs:688
13: 0x7ffd66331b43 - core::ops::function::FnMut::call_mut
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\core\src\ops\function.rs:166
14: 0x7ffd66331b43 - core::ops::function::impls::impl$3::call_mut
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\core\src\ops\function.rs:294
15: 0x7ffd66331b43 - bevy_ecs::system::function_system::impl$15::run::call_inner
at C:\Users\UserName\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_ecs-0.11.3\src\system\function_system.rs:622
16: 0x7ffd66331b43 - bevy_ecs::system::function_system::impl$15::run
at C:\Users\UserName\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_ecs-0.11.3\src\system\function_system.rs:625
17: 0x7ffd66331b43 - bevy_ecs::system::function_system::impl$6::run_unsafe,ref$ > >,futures_lite::future::impl$14::poll::closure_env$0,alloc::boxed::Box,alloc::alloc::Global> > >,futures_lite::future::CatchUnwind,async_channel::RecvError> >,futures_lite::future::Or,async_chan
at C:\Users\UserName\.cargo\registry\src\index.crates.io-6f17d22bba15001f\async-executor-1.5.4\src\lib.rs:258
30: 0x7ffd671aa1db - futures_lite::future::block_on::closure$0
at C:\Users\UserName\.cargo\registry\src\index.crates.io-6f17d22bba15001f\futures-lite-1.13.0\src\future.rs:89
31: 0x7ffd671aa1db - std::thread::local::LocalKey > >::try_with
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\thread\local.rs:270
32: 0x7ffd671aa1db - std::thread::local::LocalKey > >::with
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\thread\local.rs:246
33: 0x7ffd671aa1db - futures_lite::future::block_on,async_channel::RecvError> >,enum2$,async_channel::RecvError> >,futures_lite::future::Or::try_with
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\thread\local.rs:270
40: 0x7ffd671a962a - std::thread::local::LocalKey::with
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\thread\local.rs:246
41: 0x7ffd671a962a - bevy_tasks::task_pool::impl$2::new_internal::closure$0::closure$0
at C:\Users\UserName\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_tasks-0.11.3\src\task_pool.rs:158
42: 0x7ffd671a962a - std::sys_common::backtrace::__rust_begin_short_backtrace >
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\sys_common\backtrace.rs:154
43: 0x7ffd671ae648 - std::thread::impl$0::spawn_unchecked_::closure$1::closure$0
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\thread\mod.rs:529
44: 0x7ffd671ae648 - core::panic::unwind_safe::impl$23::call_once
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\core\src\panic\unwind_safe.rs:271
45: 0x7ffd671ae648 - std::panicking::try::do_call
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\panicking.rs:502
46: 0x7ffd671ae648 - std::panicking::try
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\panicking.rs:466
47: 0x7ffd671ae648 - std::panic::catch_unwind
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\panic.rs:142
48: 0x7ffd671ae648 - std::thread::impl$0::spawn_unchecked_::closure$1
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\thread\mod.rs:528
49: 0x7ffd671ae648 - core::ops::function::FnOnce::call_once >,tuple$<> >
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\core\src\ops\function.rs:250
50: 0x7ffd71a0e3ec - std::sys::windows::thread::Thread::new::h75a9ed52a5af2748
51: 0x7ffe10a9257d - BaseThreadInitThunk
52: 0x7ffe1214aa78 - RtlUserThreadStart
Encountered a panic in system `bevy_render::camera::camera::extract_cameras`!

```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue by toggling the bevy_pls_editor editor with the "e" key, then inspect bevy_render/src/camera/camera.rs around extract_cameras and line 688. Trace how activating a camera with is_active produces the invalid viewport value described in the report. Done means switching cameras no longer panics during camera extraction, with the behavior checked against the reported stack trace.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.