Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(desktop): compile termination callback with CEF (#8572)

Eric Hayes94b4b0d3e794
diff --git a/apps/web/src/observability/native-lifecycle.ts b/apps/web/src/observability/native-lifecycle.ts
index 9bd2e8c121..0762e7b7da 100644
--- a/apps/web/src/observability/native-lifecycle.ts
+++ b/apps/web/src/observability/native-lifecycle.ts
@@ -17,8 +17,8 @@ export function recordNativeWebviewStart(
.querySelector('meta[name="macro-bundle-build"]')
?.getAttribute('content');
const navigation = performance.getEntriesByType('navigation')[0];
- // Native snapshots include this field on every platform, but only Apple's
- // WebKit termination callback records it. Other platforms remain unknown.
+ // Native snapshots include this field on every platform, but only the iOS
+ // and macOS termination callbacks record it. Other platforms remain unknown.
const webContent =
snapshot?.identity.os === 'ios' || snapshot?.identity.os === 'macos'
? snapshot.webContent
diff --git a/apps/web/tauri/desktop-cef/AGENTS.md b/apps/web/tauri/desktop-cef/AGENTS.md
index 1d67c9be56..320cb7065a 100644
--- a/apps/web/tauri/desktop-cef/AGENTS.md
+++ b/apps/web/tauri/desktop-cef/AGENTS.md
@@ -38,6 +38,9 @@ thin binary over `../src-tauri` (`app_lib::run_with`) that selects
- The `cef` feature of `../src-tauri` adds no dependencies; it switches the
served origin to `http://tauri.localhost` and the `AppRuntime` alias to
`tauri::DynRuntime`. It only compiles in this workspace.
+- The CEF Tauri fork's `on_web_content_process_terminate` callback takes a
+ webview and termination details; the regular fork takes only a webview.
+ Check both workspaces when changing shared callback registration.
- Needs Rust 1.95 (the repo pins 1.94), `cmake`, and `ninja`; the first build
downloads about 1 GB of CEF into `~/Library/Caches/tauri-cef`.
- Nix pins Rust 1.95 and the `macro-cef` Tauri CLI separately for macOS. Keep
diff --git a/apps/web/tauri/src-tauri/README.md b/apps/web/tauri/src-tauri/README.md
index 0b83365f76..cc6f667d0c 100644
--- a/apps/web/tauri/src-tauri/README.md
+++ b/apps/web/tauri/src-tauri/README.md
@@ -40,21 +40,22 @@ Each frontend startup emits `native_webview_started` to PostHog and a
native version and launch ID, and navigation type. Native diagnostics retain
WebContent termination counts/timestamps and bundle-update reload dispatch
counts/last source across WebView replacements. Compare counters within the same
-native launch: an increased termination count identifies WebKit process recovery;
-an increased updater count identifies an app-requested update reload attempt.
+native launch: an increased termination count identifies web content process
+recovery; an increased updater count identifies an app-requested update reload
+attempt.
Dispatch does not prove the JavaScript reload completed. A new native launch ID
means the host process restarted. Missing counters on an older binary mean
unknown, not zero. The properties are also attached to subsequent PostHog events.
-Termination reporting is available on iOS and older macOS WKWebView builds. On
-Chromium macOS and other platforms,
-startup events mark it unavailable and omit termination counts/timestamps even
+Termination reporting is available on iOS and macOS, including Chromium macOS.
+Other platforms mark it unavailable and omit termination counts/timestamps even
when the native snapshot includes an unused zero-valued counter.
The Apple termination callback preserves Tauri's default reload behavior and adds
-the native evidence before reloading. It does not establish why WebKit terminated
-(for example, memory pressure versus a crash); device crash/termination reports
-are needed for that distinction. Native counters require a full app release,
-while the frontend remains compatible with older binaries.
+the native evidence before reloading. It does not establish why the web content
+process terminated (for example, memory pressure versus a crash); device
+crash/termination reports are needed for that distinction. Native counters
+require a full app release, while the frontend remains compatible with older
+binaries.
`frontend_instance_id` is generated once per document and attached to every
PostHog event (including automatic exceptions/pageviews) and OTel resource.
diff --git a/apps/web/tauri/src-tauri/src/desktop/macrod.rs b/apps/web/tauri/src-tauri/src/desktop/macrod.rs
index 5b9bcb9603..dac928fdf3 100644
--- a/apps/web/tauri/src-tauri/src/desktop/macrod.rs
+++ b/apps/web/tauri/src-tauri/src/desktop/macrod.rs
@@ -544,4 +544,3 @@ pub(crate) fn autostart(app: &AppHandle) {
}
});
}
-
diff --git a/apps/web/tauri/src-tauri/src/lib.rs b/apps/web/tauri/src-tauri/src/lib.rs
index 42d5b8ff6b..9f11f7c375 100644
--- a/apps/web/tauri/src-tauri/src/lib.rs
+++ b/apps/web/tauri/src-tauri/src/lib.rs
@@ -200,7 +200,7 @@ pub fn run_with(builder: tauri::Builder<AppRuntime>) {
#[cfg(any(target_os = "ios", target_os = "macos"))]
{
- builder = builder.on_web_content_process_terminate(|webview| {
+ let on_terminate = |webview: &tauri::Webview<AppRuntime>| {
tracing::warn!(webview = %webview.label(), "WebContent process terminated; reloading");
if let Some(state) = webview.try_state::<diagnostics::Diagnostics>() {
let _ = state.record_web_content_termination().inspect_err(|error| {
@@ -212,7 +212,16 @@ pub fn run_with(builder: tauri::Builder<AppRuntime>) {
let _ = webview.reload().inspect_err(|error| {
tracing::error!(%error, "Failed to reload terminated WebContent process");
});
- });
+ };
+ #[cfg(feature = "cef")]
+ {
+ builder = builder
+ .on_web_content_process_terminate(move |webview, _details| on_terminate(webview));
+ }
+ #[cfg(not(feature = "cef"))]
+ {
+ builder = builder.on_web_content_process_terminate(on_terminate);
+ }
}
#[cfg(desktop)]
diff --git a/apps/web/tauri/src-tauri/tauri.android.conf.json b/apps/web/tauri/src-tauri/tauri.android.conf.json
index 62b7a45317..76aaa41cef 100644
--- a/apps/web/tauri/src-tauri/tauri.android.conf.json
+++ b/apps/web/tauri/src-tauri/tauri.android.conf.json
@@ -2,7 +2,7 @@
"version": "2.5.0",
"bundle": {
"android": {
- "versionCode": 16
+ "versionCode": 17
}
},
"$schema": "https://schema.tauri.app/config/2",