Skip to content

fix[iOS]: app crash on open#1260

Merged
peterchinman merged 4 commits intomainfrom
peter/fix-ios-crashy-crashy
Jan 30, 2026
Merged

fix[iOS]: app crash on open#1260
peterchinman merged 4 commits intomainfrom
peter/fix-ios-crashy-crashy

Conversation

@peterchinman
Copy link
Copy Markdown
Contributor

@peterchinman peterchinman commented Jan 30, 2026

tauri-plugin-app-events was crashing the app. Replaced the plugin with a native iOS lifecycle observer, which triggers a Rust FFI to trigger the javascript heartbeat check.

The iOS plugin called trigger() — a Tauri Plugin base class method — from a NotificationCenter observer.
Unlike Android, where the Plugin class provides lifecycle hooks (onResume()/onPause()) that Tauri calls when
its internal state is ready, iOS has no such hooks. The plugin used NotificationCenter as a substitute, but
trigger() assumes it's being called from within Tauri's managed lifecycle. When called from an external
notification callback, the Plugin's internal event dispatcher could be null, causing a null pointer
dereference (EXC_BAD_ACCESS at 0x0).

Note that there is a Tauri PR to solve the issue that this heartbeat method resolves. When that is merged we should use that handler for web content process termination instead of the heartbeat method.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 30, 2026

#[cfg(target_os = "ios")]
#[unsafe(no_mangle)]
extern "C" fn on_app_resumed() {
let Some(handle) = GLOBAL_APP_HANDLE.get() else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

storing the app handle in a oncelock is kinda weird. We should probably follow the recommended paradigm for calling from swift -> rust, because I think most plugins do not do this.

If this works though I guess you could merge it and I could look at this as a follow up

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Jan 30, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@peterchinman peterchinman merged commit 90ad30d into main Jan 30, 2026
21 checks passed
@peterchinman peterchinman deleted the peter/fix-ios-crashy-crashy branch January 30, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants