tauri icon indicating copy to clipboard operation
tauri copied to clipboard

`window.add_child(webview_builder)` support for mobile

Open lindongchen opened this issue 1 year ago • 4 comments

Describe the bug

By viewing the source code, I'm found add_child only supports desktop, can it be compatible with mobile target? If wry is used, multiple webviews can be implemented like the following:

#[cfg(any(target_os = "ios", target_os = "android"))]
let mut builder = wry::WebViewBuilder::new().with_url(curl);

if !proxy.is_empty() {
let parts: Vec<&str> = proxy.split(':').collect();

// Access the parts safely
let proxy_host = parts.get(0).unwrap_or(&"");
let proxy_port = parts.get(1).unwrap_or(&"");
let proxy_config = wry::ProxyConfig::Socks5(wry::ProxyEndpoint {
	host: proxy_host.to_string(),
	port: proxy_port.to_string()
});

builder = builder.with_proxy_config(proxy_config);
}

let webview = builder.build_as_child(&main_window).unwrap();

But I think has some fatal issues, like not being able to access the window__ TAURI__ And I don't know how to make them public through Wry ("withGlobalTauri"= true not effective)

Multiple webviews on mobile target are a common requirement.

Reproduction

No response

Expected behavior

  1. tauri window.add_child api compatible with mobile
  2. wry creator can access window__ TAURI__
  3. have a other rust sample for mobile create multiple webviews 1 ~ 3 Just satisfy any point ,the issue will be solved

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.5.0 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.81.0 (eeb90cda1 2024-09-04)
    ✔ cargo: 1.81.0 (2dbb1af80 2024-08-20)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.18.0
    - pnpm: 8.10.5
    - yarn: 1.22.17
    - npm: 8.19.4

[-] Packages
    - tauri 🦀: 2.0.6
    - tauri-build 🦀: 2.0.2
    - wry 🦀: 0.46.3
    - tao 🦀: 0.30.5
    - @tauri-apps/api : 2.0.3
    - @tauri-apps/cli : 2.0.5

Stack trace

No response

Additional context

No response

lindongchen avatar Nov 26 '24 07:11 lindongchen

When will it be supported, or is it already in the process of follow-up?

yanyunwu avatar Feb 22 '25 14:02 yanyunwu

No ETA at all. As far as i know, nobody started to work on it yet (and for sure nobody is (still) actively working on it right now). The team is busy outside of tauri and the time they can spent on tauri is better invested elsewhere.

If you want this to be implemented any time soon you'll have to do it yourself (or find someone capable who can do it)

FabianLars avatar Feb 22 '25 14:02 FabianLars

Hi team, has there been any movement on this? Displaying webpages independently inside of a mobile app is a pretty common use case and an iframe is currently the only solution at present on mobile, which is not appropriate.

patrickjquinn avatar May 26 '25 15:05 patrickjquinn

no, my last comment is still accurate 3 months later and will probably be accurate for the rest of the year as well (like i said, unless someone wants to contribute. unlikely since this is probably quite complicated).

FabianLars avatar May 26 '25 18:05 FabianLars

I need this feature too. If nobody's working on it right now, I'll try to come up with something by myself since it's a must-have feature for my app. I can't guarantee that I'll end up with a solution that could be merged though (I actually need it for a dioxus app). Or that I'll even come up with a solution at all (I'm not qualified for the task, I'm just a random dude a little too stubborn)

Ggcpp avatar Aug 15 '25 17:08 Ggcpp

Hope someone is good at both Android and tauri, this feature is really fascinating!

Borber avatar Aug 28 '25 19:08 Borber

currently wry expects the Android webview to be a singleton, so this requires a bit of work (though I think the actual layout would be a problem, since AFAIK it is a static thing on mobile).

lucasfernog avatar Aug 29 '25 18:08 lucasfernog