tauri-apps/wry

macOS: WebView content overflows its window from v0.35.0

rhysd opened this issue · 2 comments

Describe the bug

From v0.35.0, I noticed the content of WebView overflows the window in my application. I thought it was bug in CSS of my application at the first time, but it turned out that v0.34.2 didn't have this bug.

Steps To Reproduce

  1. Install wry v0.35.0
  2. Run the following code and check the rendered content
use tao::{
  event::{Event, WindowEvent},
  event_loop::{ControlFlow, EventLoop},
  window::WindowBuilder,
};
use wry::WebViewBuilder;

const HTML: &str = "
<html>
  <body>
    <h1>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</h1>
    <div>
      Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </div>
  </body>
</html>
";

fn main() -> wry::Result<()> {
  let event_loop = EventLoop::new();
  let window = WindowBuilder::new().build(&event_loop).unwrap();
  let builder = WebViewBuilder::new(&window);
  let _webview = builder.with_html(HTML)?.build()?;

  event_loop.run(move |event, _, control_flow| {
    *control_flow = ControlFlow::Wait;

    if let Event::WindowEvent {
      event: WindowEvent::CloseRequested,
      ..
    } = event
    {
      *control_flow = ControlFlow::Exit
    }
  });
}

Expected behavior

The content fits to the window width. Please compare the screenshots in the next section.

Screenshots

v0.35.0 v0.34.2
image image

HTML content is exactly the same between the two versions. In v0.34.2, the text is word-wrapped correctly. But in v0.35.0, some text overflows before being wrapped. The width of WebView content seems longer than the width of the window.

Platform and Versions (please complete the following information):
OS: macOS 10.13
Rustc: 1.74

Would you want to assign yourself to resolve this bug?

  • Yes
  • No

Additional context

Nothing.

I noticed that this bug no longer occurred in the current HEAD of this repository. With git bisect, I confirmed that this issue didn't occur after 8fddbb6 (#1091). However, the commit is for adding a feature (a method to get WebView bounds). I'm not sure this issue was really fixed.

#1091 indeed fixed a bug related to bounds, closing for now, if it happens when the next release happens, let us know.