-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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] Lots of internal_on_mousemove IPC calls causing lag and cursor flashing in 2.0.0-beta.0 #8770
Comments
Probably should have included the error in #8750 lol. but yes, we agree that it's too hard on the ipc and will look into it. (that said, i don't see the cursor flashing) Edit: I closed my own issue cause yours is better, for visibility here's my comment from the other issue:
|
For transparency, the solution in #8537 was already used before in wry so the performance should be the same and because webview2 doesn't provide anyway to hit test the webview from native side, however on Linux, we used to use raw GTK APIs and hit test on the native side, I will see if I can bring that back. |
Something i didn't think about, this also seems to trigger #8177 |
I haven't contributed to Tauri, I may be mistaken but it appears the code this is involved in is used to:
What I'm wondering is:
Just ideas, may not be applicable or feasible. If you'd like for me to take a crack at it, I'd be happy to make my first contribution and open a branch/PR. Let me know if there is anything special I should do to get started. Otherwise I'll just check the contribution guide. Please advise. Thanks. |
the same issue,and the right and bottom cannot be resized |
Amr created a PR that is awaiting approval that fixes these issues. The OS check and permissions issue has been resolved. The OS check is now performed in Rust and checks for Windows alone, no script is attached for non-Windows platforms. And the permissions issue is avoided by using a custom invoke system ( |
The implementation of this is quite hevavy for just to change the cursor style and check able to resize. MouseMove trigger very frequently. maybe need a debounce |
Yeah, it's not ideal. From what I've heard I don't think this will end up being the final solution. Debouncing is a good idea (200ms or so?). I know Amr is looking into further efficiency improvements. I've been experimenting with possibly getting rid of the JS code entirely or involving some conditionals and fancy CSS. |
Just from what I've seen so far; I'm not sure why this couldn't be handled entirely natively in Rust using the Win32 API from the |
|
Ah I see now. It appears WebView2 can't be subclassed either so intercepting hit tests wont be possible (though I notice a tiny 1 pixel region at the top of an undecorated window shows a resizing handle on hover as it's not part of the client area). Looks like JS probably is the best solution. Small possible remaining improvements (I might give them a go but should not hold up the current PR):
|
The reason why I didn't go with this solution before, is that reloading the webview will make it lose the stored state or get out of sync. Maybe a mix of IPC and stored state could work.
Did test this idea before and it worked pretty well, however we need to use weird class names so as to not conflict with user (i.e.
I don't agree with this idea at all, since it will interfere with the user DOM hierarchy and could lead to hidden behaviors that they can't explain.
This will prevent the cursor from changing when on the window edge and users won't know if they are on a resizable edge or not. |
I ran into this issue as well and it basically made tauri unusable for me. I wrote up a quick workaround for the odd mouse behavior using the isolation pattern. When my app starts (svelte in this case) I get the window size and wait for the iframe import { Window } from "@tauri-apps/api/window";
import { onMount } from "svelte";
const win = Window.getCurrent();
let iframe: HTMLIFrameElement;
async function updateDimensions() {
if (!iframe?.contentWindow) return;
const size = await win.innerSize();
iframe.contentWindow?.postMessage(
{
type: "resize",
width: size.width,
height: size.height,
is_fullscreen: await win.isMaximized(),
},
"*"
);
}
onMount(async () => {
while (!iframe?.contentWindow) {
iframe = document.getElementById(
"__tauri_isolation__"
) as HTMLIFrameElement;
await new Promise((resolve) => setTimeout(resolve, 100));
}
await updateDimensions();
});
win.listen("tauri://resize", async () => {
await updateDimensions();
}); This is what I do in the isolation app: let width = 0;
let height = 0;
let is_fullscreen = false;
window.addEventListener("message", function (event) {
// maybe the origin should be checked and some other stuff idk
if (event.data.type === "resize") {
width = event.data.width;
height = event.data.height;
is_fullscreen = event.data.is_fullscreen;
}
});
window.__TAURI_ISOLATION_HOOK__ = (payload) => {
if (payload.cmd === "plugin:window|internal_on_mousemove") {
let x = payload.payload.x;
let y = payload.payload.y;
let min_x = 10;
let min_y = 30;
// console.log(`x: ${x}, y: ${y}, width: ${width}, height: ${height}`);
if (is_fullscreen || !(y < min_y || y > height - min_x || x < min_x || x > width - min_x)) {
payload.cmd = "nothing";
payload.payload = {};
}
}
return payload;
}; It still spams ipc calls which isn't ideal and I'm waiting for a fix but this fixes the stuttering issue and be sure to make a tauri command that doesn't do anything so that the console isn't spammed with errors about the endpoint not existing. Edit: I don't see why this behavior is needed if the app is decorated so in the code i sent above you can use |
Encountered the same issue but without cursor blinking. |
bug: tauri-apps/tauri#8770 bug: src-tauri/src/utils/server.rs#L56-L80
closes tauri-apps#7388 closes tauri-apps#9510 closes tauri-apps#9464 ref tauri-apps#9268 ref tauri-apps#9053 ref tauri-apps#8770 ref tauri-apps#8750 ref tauri-apps#4012
Describe the bug
After migrating from Tauri V1 to V2 beta, when I move my mouse cursor over a button, the pointer "hand" symbol flashes between a normal cursor and the hand. A lot of traffic is observed in the Network tab of the devtools directed at this endpoint (http://ipc.localhost/plugin%3Awindow%7Cinternal_on_mousemove). Removing "window:default" in "/src-tauri/capabilities/mycapabilities.json" stops the flashing but then a lot of errors are logged in the console. I attempted to make a project from scratch and noted the same issue.
Attempted Fixes:
Cursor flash on hover/move with "window:default" enabled
2024-02-04_23-39-27.mp4
Console errors with "window:default" disabled
2024-02-05_00-37-58.mp4
Reproduction
pnpm create tauri-app --alpha
npm install
in project directorynpm run tauri dev
Expected behavior
Full
tauri info
outputStack trace
Additional context
The text was updated successfully, but these errors were encountered: