Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that multiple windows are not supported on Android #3505

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ use serde::{Deserialize, Serialize};
///
/// ## Platform-specific
///
/// **Web:** The [`Window`], which is represented by a `HTMLElementCanvas`, can
/// not be closed by dropping the [`Window`].
/// - **Web:** The window is represented by a `HTMLElementCanvas`, and cannot
/// currently be closed by dropping the [`Window`].
/// - **Android:** Each window is spawned inside its own process, and as such
Copy link
Member

@MarijnS95 MarijnS95 Mar 13, 2024

Choose a reason for hiding this comment

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

Copy-pasting my reply in #696 (comment):

on Android each window is run in its own process

Not at all, anything related to the same app (services, multiple Activities which are probably the closest synonym to Windows) should all run in the same process.

This is actually an open issue, where certain Android system interactions can cause it (the Android system) to launch another Activity one is already open via a callback. Both android-activity and winit are assuming there is only one Activity singleton with (related) state stored across various static globals, and everything falls apart.

It is however unlikely to have multiple windows open at the same time, bar tricks with multiple task stacks, split-window, popout windows and perhaps desktop mode.

I wouldn't mention process boundaries at all. Rather:

  1. Spawning windows in Android most likely doesn't perform in the way the user expects. This could navigate to a different "page" in an app but it's not at all like the desktop experience;
  2. The Android system can spawn new "windows" (Activities) for you (e.g. an app resize or display mode change, or via public Intents launched by other apps) on its own behalf.

/// Winit does not support multiple windows on Android. Create a new
/// activity instead.
pub struct Window {
pub(crate) window: platform_impl::Window,
}
Expand Down