Skip to content

feat(mobile): multi window support - #1633

Merged
FabianLars merged 12 commits into
devfrom
feat/mobile-multi-webview
Mar 22, 2026
Merged

feat(mobile): multi window support#1633
FabianLars merged 12 commits into
devfrom
feat/mobile-multi-webview

Conversation

@lucasfernog

Copy link
Copy Markdown
Member

follow-up for tauri-apps/tao#1154

includes a refactor to only load Android library once

@github-actions

github-actions Bot commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Package Changes Through 5c83d7b

There are 1 changes which include wry with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
wry 0.54.4 0.55.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

Comment thread src/wkwebview/mod.rs
// set all autoresizingmasks
webview.setAutoresizingMask(UIViewAutoresizing::from_bits(31).unwrap());
// let () = msg_send![webview, setAutoresizingMask: 31];
webview.setAutoresizingMask(

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.

This sets the autoresizing mask for the webview, which is the legacy (pre-Auto Layout) way of handling view resizing in iOS.

  • Doesn't automatically respect safe areas (notch, home indicator etc)
  • Webview may extend under system UI elements
  • Needs additional code to handle safe area insets

It may be worth considering moving to Auto Layout e.g.

webview.setTranslatesAutoresizingMaskIntoConstraints(false);

// Add constraints to fill parent while respecting safe area
NSLayoutConstraint::activateConstraints(&[
  webview.topAnchor().constraintEqualToAnchor(&parent.safeAreaLayoutGuide().topAnchor()),
  webview.bottomAnchor().constraintEqualToAnchor(&parent.safeAreaLayoutGuide().bottomAnchor()),
  webview.leadingAnchor().constraintEqualToAnchor(&parent.safeAreaLayoutGuide().leadingAnchor()),
  webview.trailingAnchor().constraintEqualToAnchor(&parent.safeAreaLayoutGuide().trailingAnchor()),
]);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

that's something we should investigate in a separate PR - my first attempt resulted in a crash
and I believe this would be consider a breaking change too, most users offset the notch etc via HTML

Comment thread src/android/main_pipe.rs
}

pub fn first_activity_id() -> Option<ActivityId> {
ACTIVITY_PROXY.lock().unwrap().keys().next().cloned()

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.

Possible race condition if activities are destroyed while being accessed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ACTIVITY_PROXY is a mutex and first_activity_id is only used in cases where the actual activity instance doesn't matter

override fun onStop() {
super.onStop()
stop()
id = savedInstanceState?.getInt(ACTIVITY_ID_KEY) ?: intent.extras?.getInt(ACTIVITY_ID_KEY) ?: hashCode()

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.

hashCode() fallback could theoretically produce duplicate IDs, breaking message routing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

that's why we are persisting the id in the saved instance state

Comment thread src/android/mod.rs
pub static EVAL_ID_GENERATOR: Counter = Counter::new();
pub static EVAL_CALLBACKS: OnceCell<Mutex<HashMap<i32, EvalCallback>>> = OnceCell::new();

pub fn destroy_webview(activity_id: ActivityId, webview_id: &WebviewId) {

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.

While it doesn't pose a significant memory leak, do we have a similar function i.e. destroy_activity(..) where we clean up ACTIVITY_PROXY?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

nice catch, 8d88361

@FabianLars
FabianLars merged commit 781f371 into dev Mar 22, 2026
24 checks passed
@FabianLars
FabianLars deleted the feat/mobile-multi-webview branch March 22, 2026 20:54
chriscraws pushed a commit to chriscraws/wry that referenced this pull request May 13, 2026
Co-authored-by: FabianLars <30730186+FabianLars@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants