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

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

Open
lindongchen opened this issue Jun 11, 2024 · 5 comments
Open

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

lindongchen opened this issue Jun 11, 2024 · 5 comments
Labels
platform: Windows status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@lindongchen
Copy link

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

@lindongchen lindongchen added status: needs triage This issue needs to triage, applied to new issues type: bug labels Jun 11, 2024
@dklassic
Copy link
Contributor

dklassic commented Jun 12, 2024

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

  • wry's proxy support does work on Windows 11 for both http and socks5, building a window using wry with with_proxy_config totally works.
  • However the window created with proxyUrl argument using tauri will immediately result in the window spawning and closing.
  • Additional investigation shows this window created by tauri isn't closed properly, as crash callback isn't raised and additional attempt at creating the same window after the first one closes will result in the error "a webview with label my-label already exists".

@lindongchen
Copy link
Author

lindongchen commented Jun 12, 2024

企业微信截图_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
Copy link
Author

lindongchen commented Jun 13, 2024

#[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

@jasonhao518
Copy link

this is my code, it works on mac, but stuck on Windows, showing a white screen. tauri version is 2.0.0.rc-11 with macos-proxy enabled.

#[tauri::command]
fn openWindow(app: tauri::AppHandle, label: &str, title: &str, urlString: &str) {
let webview_window =
tauri::WebviewWindowBuilder::new(&app, label, tauri::WebviewUrl::App(urlString.into()))
.inner_size(800.0, 600.0)
.title(title)
.proxy_url(Url::parse("socks5://localhost:1080").expect("REASON"))
.build();
}

@ghost
Copy link

ghost commented Sep 21, 2024

I would like to inquire whether the bug related to the use of SOCKS5 proxies in Tauri has been resolved.
@lucasfernog @liushuyu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: Windows status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

4 participants