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

Html content not displaying, but can be selected. #17

Open
cessen opened this issue Sep 4, 2022 · 14 comments
Open

Html content not displaying, but can be selected. #17

cessen opened this issue Sep 4, 2022 · 14 comments

Comments

@cessen
Copy link

cessen commented Sep 4, 2022

I have a simple project with the following code, based on the example in the docs:

use fltk::{app, prelude::*, window::Window};

fn main() {
    let app = app::App::default();
    let mut win = Window::default()
        .with_size(800, 600)
        .with_label("Hi there!");
    
    let mut webview_win = Window::default()
        .with_size(790, 590)
        .center_of_parent();
    
    win.end();
    win.make_resizable(true);
    win.show();
    
    let webview = fltk_webview::Webview::create(true, &mut webview_win);
    webview.set_html(r#"
<!doctype html>
<html>
    <head>
        <title>A title.</title>
    </head>
    <body style="color: rgb(0, 0, 0);">
        <h1>Hi there!</h1>
        <p>This is a test.</p>
    </body>
</html>
    "#);
    
    app.run().unwrap();
}

It compiles and runs just fine, but the view is blank:

fltk_webview

Interestingly, if I right-click and bring up the inspector, the content does seem to be there:

fltk_webview_inspector

Furthermore, the cursor changes to the text cursor when I hover over the areas where the text ought to be displayed, and I can drag-select (without any visible highlighting) and copy it, and paste the content into a text editor, and that works correctly with the expected content of the page being pasted.

At first I thought it might be a styling thing (e.g. the text is rendered white), but that doesn't seem to be the case, and is the reason for the style attribute on the body.

If I try to open a website with the navigate() method the same thing happens: the expected content seems to be there (shows up in the inspector, can be (invisibly) selected and copy/pasted into other applications), but just not rendered.

This feels particularly bizarre since the inspector obviously draws just fine—no idea why it would be able to draw that but not the actual web content.

I realize this may be a tricky bug to track down, and seems like the kind of thing that might be system-specific. So I'm ready to provide any help I reasonably can. Please let me know if there's anything you want me to check/test, etc.

System Info

I'm running NixOS 22.05 with X11 and AwesomeWM. Hardware-wise, I'm on an AMD x86/64 system with nVidia graphics (with the proprietary drivers). I can provide more details if that would be helpful.

@MoAlyousef
Copy link
Collaborator

Hi

The situation on linux is kind of a mess because of the availability/features of different window managers.
For example, on kwin this works. On gnome mutter it works but has some flickering. On clutter it apparently doesn’t. Wayland also doesn’t support embedding/XEmbed for security reasons.
This really makes fltk-webview not suitable for linux unfortunately.

You can try to make it work on awesomeWM by testing whether the following works:

if win_manager("gnome-session") {

By changing it to if !win_manager("gnome-session") { and see if that helps. From what I understand from quickly looking online is that awesomeWM doesn’t support XEmbed:
https://www.reddit.com/r/awesomewm/comments/pk7580/awesomewm_tray_remmina_and_deprecated_xembed/?utm_source=share&utm_medium=ios_app&utm_name=iossmf

@cessen
Copy link
Author

cessen commented Sep 6, 2022

Thank you for the quick response!

The situation on linux is kind of a mess because of the availability/features of different window managers.

Ah, that makes sense.

You can try to make it work on awesomeWM by testing whether the following works:

Unfortunately, that didn't help. Same result as before.

To reiterate: part of what is odd about this is that the inspector shows up just fine, which I assume is part of the webview? Not sure if that's a clue that helps or not.

Please let me know if there's anything else I can test, or additional information I can provide.

@MoAlyousef
Copy link
Collaborator

The issue seems very similar to the issue reported against tauri:

tauri-apps/tauri#5143

It might be related to the webkit version. I’ll try to follow the discussion there as if progresses since it might shed light into this issue.

@cessen
Copy link
Author

cessen commented Sep 7, 2022

Okay, thank you!

@vitali2y
Copy link

Standard examples (basic.rs, bind.rs) visually are blank (although content is okay, e. g. invisible Google's logo @ basic.rs is possible to drag-and-drop) after successful compilation @ Linux Mint 21 + Cinnamon.

@ohmyarch
Copy link

Same on Arch Linux/GNOME 45.3/Mutter, but wry works fine, it use webkit2gtk 4.1 on Linux.

@ohmyarch
Copy link

I found something new: https://gitlab.gnome.org/World/Rust/webkit6-rs, is it possible to integrate with fltk-rs?

@MoAlyousef
Copy link
Collaborator

MoAlyousef commented Jan 17, 2024

I’ve released version 0.4 today which also uses webkit2gtk 4.1.
The problem generally is from mutter itself allowing fltk to embed the webview window.

I’ll take a look at webkit-rs.

@ohmyarch
Copy link

error[E0432]: unresolved import `wv::Webview`
 --> /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fltk-webview-0.4.0/src/lib.rs:9:9
  |
9 | pub use wv::Webview;
  |         ^^^^^^^^^^^ no `Webview` in the root

It may also be necessary to release a new version for fltk-webview-sys.

@ohmyarch
Copy link

And https://docs.rs/crate/fltk-webview/0.4.0 is broken.

@ohmyarch
Copy link

Unfortunately, newer versions of webkit2gtk still don't work, and the problem may be caused by the way the webview is embedded.

@ohmyarch
Copy link

Maybe it would be helpful to take a deeper look at how wry handles it, which supports both X11 and Wayland.

@MoAlyousef
Copy link
Collaborator

wry doens't do any embedding. In livid-desktop I do the same with the webview.
What fltk-webview does on linux is to take the webview's Gtk window and tries to embed it using XReparentWindow.
The issue is that with some window managers like Gnome's Mutter, this won't work since it tries to re-reparent the window.
On KDE plasma and other X11 window manager, this appears to work.

You can try to clone the repo and run the examples while changing the if win_manager("gnome-session") to if !win_manager("gnome-session") in fltk-webview/src/lib.rs and see if that helps. Last I tried was a few years ago I might give it another shot sometime later, maybe newer versions of mutter are different!

@ohmyarch
Copy link

I did try forking and testing if !win manager("gnome-session") but that didn't work either, probably makes no difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants