Repository: zng-ui/zng (language: rust)

Issue:
Crash handler does not recover from `run_same_process` apps
<!--
Please, make sure:

- The issue happens in the latest crate release or newer (master branch).
- The issue happens after `cargo update`.
-->

#### I tried this code:

```rust
use zng::prelude::*;

fn main() {
    examples_util::print_info();
    zng::app::crash_handler::init_debug();
    zng::view_process::default::run_same_process(app_main);
}

fn app_main() {
    APP.defaults().run_window(async {
        Window! {
            child = Button! {
                child = Text!("Crash");
                on_click = hn_once!(|_| panic!("CRASH!"));
            };
        }
    });
}

```

#### Following these steps:

1 - Run.

#### I saw this happen:

Crash and app exit.

#### I expected this to happen:

Debug dialog to show.

#### Error log or stack trace:

<details>
  <summary>stderr</summary>

```
   Compiling examples v0.0.0 (C:\code\zng\examples)
    Finished dev [unoptimized + debuginfo] target(s) in 11.27s
     Running `target\debug\examples\test.exe`
 INFO zng_app::crash_handler: crash monitor-process is running
 INFO zng_app::crash_handler: app-process is running
 INFO zng_view: running headed view-process
    <removed>
 INFO zng_webrender::renderer::init: using KHR    
thread '<unnamed>' panicked at examples\examples\test.rs:14:41:
   CRASH!
widget path:
   WindowId(1)//Window!(3)/Button!(2)
stack backtrace:
    <removed>

 INFO zng_webrender::render_backend: Recycling stats: Recycler { num_allocations: 0 }    
 INFO zng_app::crash_handler: crash monitor-process exiting with success code (0), 0 crashes
```

</details>


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f63997f91..2e9de2b00 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,7 @@ fn version_0_5() -> impl UiNode {
 }
 ```
 * **Breaking** Rename `VarCapabilities` to `VarCapability`.
+* Fix `zng::view_process::default::run_same_process` not propagating app panics.
 
 # 0.4.0
 
diff --git a/crates/zng-view/src/lib.rs b/crates/zng-view/src/lib.rs
index e87013d6b..3ef99bb08 100644
--- a/crates/zng-view/src/lib.rs
+++ b/crates/zng-view/src/lib.rs
@@ -237,7 +237,7 @@ pub fn run_same_process(run_app: impl FnOnce() + Send + 'static) {
 
 /// Like [`run_same_process`] but with custom API extensions.
 pub fn run_same_process_extended(run_app: impl FnOnce() + Send + 'static, ext: fn() -> ViewExtensions) {
-    thread::Builder::new().name("app".to_owned()).spawn(run_app).unwrap();
+    let r = thread::Builder::new().name("app".to_owned()).spawn(run_app).unwrap();
 
     let config = ViewConfig::wait_same_process();
     config.assert_version(true);
@@ -249,6 +249,10 @@ pub fn run_same_process_extended(run_app: impl FnOnce() + Send + 'static, ext: f
     } else {
         App::run_headed(c, ext());
     }
+
+    if let Err(p) = r.join() {
+        std::panic::resume_unwind(p);
+    }
 }
 
 #[cfg(feature = "ipc")]


Test patch: