-
Notifications
You must be signed in to change notification settings - Fork 7
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
Linux|X11 example glitches and high CPU load #2
Comments
Hi |
To better reproduce this i installed Fedora 34 (https://download.fedoraproject.org/pub/fedora/linux/releases/34/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-34-1.2.iso) in VirtualBox and it pretty much looks the same (if a switch to the dark adwaita theme because if the rectangle is dark or not depends on the gnome theme). On top of my head i think i just needed to install this
cloned the webview repo and |
Thanks. I’ll try to repro with this setup. |
I see the glitches on the fedora vm. The issue seems to be with
|
on my machine both commands yield
So i don't think that is the particular reason but i do think it has something to do with the reparenting. Testing the |
Looking for similar issues, I found this. It seems on gnome the window manager tries to reparent the window, which is why repeated calls to XReparentWindow show the tearing effect. I'll try looking into this issue closely during the weekend. |
just out of curiosity what exactly is the reason not to use "just" inner = wv::webview_create(
debug as i32,
&mut win.raw_handle() as *mut *mut raw::c_void as *mut raw::c_void,
); like on the windows branch? I thought that Because the current version still says // Creates a new webview instance. If debug is non-zero - developer tools will
// be enabled (if the platform supports them). Window parameter can be a
// pointer to the native window handle. If it's non-null - then child WebView
// is embedded into the given parent window. Otherwise a new window is created.
// Depending on the platform, a GtkWindow, NSWindow or HWND pointer can be
// passed here.
WEBVIEW_API webview_t webview_create(int debug, void *window); I would assume the same is true for EDIT: I think i get it EDIT2: GtkWindow* GetGtkWindowFromX11Window(XID xid) {
GdkWindow* gdk_window =
gdk_x11_window_lookup_for_display(gdk_display_get_default(), xid);
if (!gdk_window)
return NULL;
GtkWindow* gtk_window = NULL;
gdk_window_get_user_data(gdk_window,
reinterpret_cast<gpointer*>(>k_window));
if (!gtk_window)
return NULL;
return gtk_window;
} |
Did a little testing but i am just not familiar with GTK/X11 and probably mixed some things up. I added let cflags = std::process::Command::new("pkg-config")
.args(&["--cflags", "gtk+-3.0", "x11"])
.output()
.expect("Needs pkg-config and gtk installed"); and added #include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <X11/X.h>
#include <stdio.h>
long my_get_xid(GdkWindow *win) { return GDK_WINDOW_XID(win); }
GdkWindow *my_get_win(GtkWindow *win) {
GdkWindow *w = gtk_widget_get_window(GTK_WIDGET(win));
return w;
}
GtkWindow* GetGtkWindowFromX11Window(XID xid) {
printf("C xid is %lu\n", xid);
printf("C default display is %lu\n", gdk_display_get_default());
GdkWindow* gdk_window =
gdk_x11_window_lookup_for_display(gdk_display_get_default(), xid);
printf("C gdk_window is %lu\n", gdk_window);
if (!gdk_window)
return NULL;
GtkWindow* gtk_window = NULL;
gdk_window_get_user_data(gdk_window,(gpointer*)(>k_window));
printf("C gtk_window is %lu\n", gtk_window);
if (!gtk_window)
return NULL;
return gtk_window;
} and altered the linux branch of #[cfg(target_os = "linux")]
{
use std::os::raw::*;
// pub enum GdkWindow {}
pub enum GtkWindow {}
// pub enum Display {}
pub enum XID {}
extern "C" {
pub fn gtk_init(argc: *mut i32, argv: *mut *mut c_char);
// pub fn my_get_win(wid: *mut GtkWindow) -> *mut GdkWindow;
// pub fn my_get_xid(w: *mut GdkWindow) -> u64;
// pub fn XReparentWindow(
// display: *mut Display,
// w: u64,
// parent: u64,
// x: i32,
// y: i32,
// );
// pub fn XMapWindow(display: *mut Display, w: u64);
// pub fn XFlush(disp: *mut Display);
pub fn GetGtkWindowFromX11Window(xid: *mut XID) -> *mut GtkWindow;
}
// this is necessary or `gdk_display_get_default` from gtkwid.c::GetGtkWindowFromX11Window
// always returns `NULL`
gtk_init(&mut 0, std::ptr::null_mut());
let xid_handle = win.raw_handle();
println!("r xid handle: {:?}", xid_handle);
let gtk_handle = GetGtkWindowFromX11Window(xid_handle as _);
println!("r gtk handle: {:?}", gtk_handle);
inner = wv::webview_create(
debug as i32,
gtk_handle as *mut *mut raw::c_void as *mut raw::c_void,
);
// gtk_init(&mut 0, std::ptr::null_mut());
// inner = wv::webview_create(debug as i32, std::ptr::null_mut() as _);
// assert!(!inner.is_null());
// let temp_win = wv::webview_get_window(inner);
// let temp = my_get_win(temp_win as _);
// assert!(!temp.is_null());
// let xid = my_get_xid(temp as _);
// let flxid = win.raw_handle();
// XReparentWindow(app::display() as _, xid, flxid, win.x(), win.y());
// XMapWindow(app::display() as _, xid);
// XFlush(app::display() as _);
// win.draw(move |w| {
// wv::webview_set_size(inner, w.w(), w.h(), 0);
// });
} without much success. The console output is
so for some reason the line GdkWindow* gdk_window =
gdk_x11_window_lookup_for_display(gdk_display_get_default(), xid); is failing and i don't really know why. Interestingly enough
and one of them |
Yeah Gtk methods to derive an XID are specifically made for Gtk widgets/windows that already have a GdkWindow member. Unfortunately things aren't documented as such. I had previously asked on the gnome discourse: |
Yes its definitely better – lesser CPU load and the website is more usable (being able to click links, scroll and typing etc. occasionally in between the "flicker" events ) – but still not really usable because of the constant shift of the website. I am unsure where to go from here and how to reach out ... maybe create a pure C fltk demo and post on stackoverflow? |
Yeah I’ll probably do that eventually if all else fails. I have a few things to try first, like handling the reparent notify event. |
Can you try the latest changes on your machine, it appears to be working on the fedora vm. |
Are you sure its working on the Fedora vm and you have pushed all the changes? I pulled the latest changes (ddbcf94) both on my Arch machine and the Fedora vm and both behave the same by just showing a white window and it looks like i am not able to interact with the "invisible" content (like i could with the black rectangle by highlighting and dragging text etc.) I also noticed that while the |
I’ve posted a question on the fltk mailing list with a repro in C++, the similar questions on stackoverflow have no satisfactory answers. I’ve tried handling the X11 ReparentNotify event but it doesn’t always register for some reason. Using a simple gtk3 window I don’t get the repeated movements in the window, it does require though repeated reparenting, it seems the webkit2gtk window does some things on its own, which will require further investigation. |
Hi |
I am running the webview example and have noticed quite some problems.
I am running:
on X11 right now (i'll check wayland later) i have some glitches while running it. First there is a very high CPU load that seems to be a symptom of what looks like that the webview is recreated multiple times. In the attached video you can see that in the application window itself the rendered website "jumps" around. I have tested this with multiple websites and i don't think it has anything to do with rendering glitches of the website with the rendering engine. I made a dual monitor capture because one thing i notices was that my "Dock" on left monitor was hiding and showing rapidly while the example was running. To give a little context here – i have a System-Monitor running in "Fullscreen" on the left monitor and in that case the "Dock" is hiding (it does while every time the focused widow would overlap it). While running the example i noticed "flashing" "mirrors" of the website that gets rendered for brief millisecons (unfortunatly it does not show on the screen capture) but the "Dock" hiding and showing indicates that for a brief moment another window is obscuring the System-Monitor and had focus. After running the example i have occasionally a "dead" window open on the exact place the "flashing" was happening after the example gets closed and i can't close that.
For me it looks like as if the webview is created rapidly multiple times and gets attached to the "main" view (resulting in the jumping of website content) and sometimes that does not work and the webview gets its "own" window poping up on the left monitor and gets closed immediately and sometimes the example application gets closed in between resulting in the "dead" window.
smaller_webview.mp4
better version of the video github only allows mp4 and i don't want the files to get overly large.
The "jumping" and "Dock" hiding etc is much more quickly without the video capturing.
screenshot of the leftover "dead" window on the left screen on the position the short lived copy of the second window
The text was updated successfully, but these errors were encountered: