tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
79.08k stars 2.35k forks source link

[bug] webview sock5 proxy_url not activate on windows 11 #10037

Open lindongchen opened 6 days ago

lindongchen commented 6 days ago

Describe the bug

The following seems to be compatibility issues, which have been verified by macos 14 and are effective 1. webview sock5 proxy_url not activate on windows 11, but macos 14 is activated. Is it still not supported, or is there a special configuration for the windows plm.

import { getCurrent } from '@tauri-apps/api/window'
...
const webview = new Webview(getCurrent(),`${app.name}-webview`, {
    url: app.url,
    proxyUrl:'sock5://....'
    title: app.name,
    width:960
});

  1. By the way, I would like to confirm new WebviewWindow will crash in Windows system, But the console has no errors, tauri://created Triggered tauri://error Not triggered Is it because the window API still doesn't support on wins plm?

Reproduction

No response

Expected behavior

Confirm support and plan

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.5.0 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.77.0 (aedd173a2 2024-03-17)
    ✔ cargo: 1.77.0 (3fe68eabf 2024-02-29)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 21.7.1
    - pnpm: 8.10.5
    - yarn: 1.22.17
    - npm: 6.14.17

[-] Packages
    - tauri [RUST]: 2.0.0-beta.22
    - tauri-build [RUST]: 2.0.0-beta.17
    - wry [RUST]: 0.40.1
    - tao [RUST]: 0.28.0
    - @tauri-apps/api [NPM]: 2.0.0-beta.13
    - @tauri-apps/cli [NPM]: 2.0.0-beta.20

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../../agent/gui
    - devUrl: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

Stack trace

No response

Additional context

No response

dklassic commented 5 days ago

This one is rather curious, I did some digging and here are some characteristics I've found so far:

lindongchen commented 5 days ago
企业微信截图_5dde284a-c6f5-40c2-8134-6318a9c79aac

https://github.com/tauri-apps/wry/pull/1006/files#diff-7134ef3789fee9def2afb1d6196ed5eff5f37b7bbad5eceaa5d85cbf3e3513de Yeah , I have reviewed wry's code and added socks5 and HTTP proxies for webview2

I can use new Windows into new Webview separately without using WebviewWindow. It works and not crashing, but the proxy is still invalid I think just https://github.com/tauri-apps/tauri/blob/dev/core/tauri/src/webview/plugin.rs#WebViewConfig missing proxy_url definition

lindongchen commented 4 days ago
#[command]
async fn create_wry_webview(
    app: tauri::AppHandle,
    label: String,
    window_label: String,
    proxy_host: String,
    proxy_port: String,
    curl: String,
) -> Result<(),()> {
    unsafe {
        let window = app
            .get_window(&window_label)
            .expect("Failed to find window by label");

        let proxy_config = wry::ProxyConfig::Socks5(wry::ProxyEndpoint {
            host: proxy_host,
            port: proxy_port
        });

        let builder = wry::WebViewBuilder::new_as_child(&window);
        let webview = builder
          .with_url(curl)
            .with_proxy_config(proxy_config)
            .with_bounds(wry::Rect {
                position: tauri::LogicalPosition::new(100, 100).into(),
                size: tauri::LogicalSize::new(960, 800).into(),
              })
          .build()
          .unwrap();
    }
    Ok(())
}
import { getCurrent,Window } from '@tauri-apps/api/window'
import { invoke } from '@tauri-apps/api/core';
...
options.parent = getCurrent();
const appWindow = new Window(`${app.name}-window`,options);

appWindow.once('tauri://created', function () {
                 invoke('create_wry_webview', {
                                windowLabel:`xxx-window`,
                                label:`xxx-webview`,
                                curl:'https://chatgpt.com/',
                                proxyHost: '127.0.0.1',
                                proxyPort: `1234`
                 });
 });

@dklassic When I tried to create a webview using wry(0.41.0) and set "with_proxy_config", I opened a blank window while running Win11. After a while, the window froze (it didn't immediately froze, it froze for a few seconds), and I ruled out other reasons. The froze was caused by with_proxy_config, So with_proxy_config not working and caused the window to freeze

Cloud you help me check the code issue? Thanks