We've developed a screen-sharing app using Tauri that relies on a foreground service to continue screencasting even when the app is in the background. It’s common for the operating system to terminate the MainActivity when the app is in the background, but the service continues to run and send screencast frames to the Rust backend.
The issue arises when we relaunch the app: the Tauri application attempts to recreate the webview, leading to an exception (details provided in the attached text file). I am also sharing the complete logs for additional context.
What is the best practice for handling app relaunches in scenarios where the app's lifecycle extends beyond that of the MainActivity?