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

winit: initial minibrowser #29976

Merged
merged 44 commits into from Aug 15, 2023
Merged

winit: initial minibrowser #29976

merged 44 commits into from Aug 15, 2023

Conversation

delan
Copy link
Member

@delan delan commented Jul 6, 2023

This patch introduces a new minibrowser mode, enabled by running the winit port with --minibrowser.

The minibrowser has a location bar and a go button. The location bar updates to reflect the URL of the top-level browsing context, unless the user has started editing the location without clicking go.

It has been tested on Linux with X11, but should also work with Wayland and on Windows and macOS.

image

Some changes to the compositor were necessary to allow Servo and our minibrowser code to cooperatively draw to the same OpenGL framebuffer. Normally the compositor “presents” each new frame (swapping buffers) as soon as WebRender has drawn to it, but we need to make sure that both WebRender and the minibrowser are repainted on every frame. Failing to do so leads to strange glitches where new frames get overwritten with stale framebuffer contents.

We add an external­_present mode that instead notifies the embedder (via the constellation) that a new frame is ready, allowing the embedder to draw other things to the framebuffer. In external­_present mode, the compositor does not run again until the embedder calls present, to ensure consistency of WebRender output, and IO­Compositor­::clear­_background no longer clears the whole framebuffer, only the viewport area.

Some optimisations were also necessary to make this performant:

  • we add a Browser field that tracks the current top-level URL as a string, so we can avoid repeated serialisation
  • we vendor and modify EguiGlow to retain its shapes, so we can repaint the minibrowser without an egui update
  • when egui needs an update, we defer it through a winit redraw request, so we can coalesce updates over events

  • There are tests for these changes OR
  • These changes do not require tests because it would be impractical to test the minibrowser directly, but we may be able to unify the codepaths so the minibrowser is indirectly tested with WPT

ports/winit/app.rs Outdated Show resolved Hide resolved
ports/winit/app.rs Outdated Show resolved Hide resolved
bors-servo added a commit that referenced this pull request Jul 13, 2023
Minibrowser: Introduce minibrowser.enabled prefs

Introducing minibrowser.enabled prefs in preparation of #29976

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
bors-servo added a commit that referenced this pull request Jul 13, 2023
Minibrowser: Introduce minibrowser.enabled prefs

Introducing minibrowser.enabled prefs in preparation of #29976

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
@servo-wpt-sync
Copy link
Collaborator

🛠 These changes could not be applied onto the latest upstream WPT. Servo's copy of the Web Platform Tests may be out of sync.

@servo-wpt-sync
Copy link
Collaborator

🛠 These changes could not be applied onto the latest upstream WPT. Servo's copy of the Web Platform Tests may be out of sync.

@servo-wpt-sync
Copy link
Collaborator

🛠 These changes could not be applied onto the latest upstream WPT. Servo's copy of the Web Platform Tests may be out of sync.

@servo-wpt-sync
Copy link
Collaborator

🛠 These changes could not be applied onto the latest upstream WPT. Servo's copy of the Web Platform Tests may be out of sync.

@servo-wpt-sync
Copy link
Collaborator

🛠 These changes could not be applied onto the latest upstream WPT. Servo's copy of the Web Platform Tests may be out of sync.

ports/winit/app.rs Outdated Show resolved Hide resolved
@delan delan marked this pull request as ready for review August 10, 2023 06:56
Copy link
Member

@mrobinson mrobinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for walking through this with us. I'm excited about this functionality! I just have a few suggestions.

ports/winit/Cargo.toml Outdated Show resolved Hide resolved
ports/winit/app.rs Outdated Show resolved Hide resolved
ports/winit/app.rs Outdated Show resolved Hide resolved
ports/winit/app.rs Outdated Show resolved Hide resolved
ports/winit/browser.rs Outdated Show resolved Hide resolved
ports/winit/app.rs Outdated Show resolved Hide resolved
ports/winit/app.rs Outdated Show resolved Hide resolved
ports/winit/browser.rs Outdated Show resolved Hide resolved
@delan delan requested a review from mrobinson August 14, 2023 09:27
Copy link
Member

@mrobinson mrobinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these updates. This looks great!

@mrobinson mrobinson added this pull request to the merge queue Aug 15, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 15, 2023
@mrobinson mrobinson added this pull request to the merge queue Aug 15, 2023
Merged via the queue into servo:master with commit 2778bee Aug 15, 2023
9 of 10 checks passed
@delan delan deleted the minibrowser branch August 15, 2023 09:45
@atbrakhi atbrakhi mentioned this pull request Aug 16, 2023
3 tasks
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

Successfully merging this pull request may close these issues.

Servo embedding: Create a mini-browser
5 participants