Commit graph

13 commits

Author SHA1 Message Date
Sebastian C
27c8a899ea
Replace hsts preload list hashmap with an FST (#37015)
This reduces the memory used by the preload list to just 1.9MB. The
total memory savings in HSTS from
pre-103cbed928
is now 62MB, or 96%. And in terms of total resident memory is a 7.5%
reduction. The DAFSA/DAWG used by Firefox is 1.1MB so there could be
additional gains available but this seems like the best option based on
maintained libraries available (I could not find a good maintained
library for DAFSAs in Rust).

The main trick is this: the FST map API is currently designed to map
byte sequences to u64 values. Because we only need to determine if a
preloaded domain has the `includeSubdomains` flag set, we encode that
into the lowest bit of the ids in the map. This way finding an entry in
the map directly provides us with the `includeSubdomains` flag and we
don't need to keep another mapping in memory or on disk.

Updated the `./mach update-hsts-preload` command to generate the new FST
map file. (Not sure if I need to update any dev-dependencies anywhere
for this change)

This change also replaces the use of "mozilla.org" with "example.com" in
the HSTS unit tests to make sure that entries in the preload list do not
influence the tests (since example.com should not ever end up on the
preload list)

Testing: Updated unit tests
Fixes: #25929

---------

Signed-off-by: Sebastian C <sebsebmc@gmail.com>
2025-05-20 04:26:55 +00:00
webbeef
3db0194e5a
Embed user agent stylesheets and media control resouces in libservo (#36803)
Embed user agent stylesheets and media control resouces in libservo as
decided in
https://github.com/servo/servo/pull/36788#issuecomment-2845332210

Signed-off-by: webbeef <me@webbeef.org>
2025-05-04 18:48:09 +00:00
Jonathan Schwender
d7e560c9c0
resources: Remove baked in resources (#36042)
This allows removing a LazyLock around the resources.
We override the baked in resources unconditionally in servoshell
upon initialization anyway
([desktop](9f93ccd942/ports/servoshell/desktop/cli.rs (L15)),
[android](9f93ccd942/ports/servoshell/egl/android/simpleservo.rs (L49)),
[ohos](9f93ccd942/ports/servoshell/egl/ohos/simpleservo.rs (L43))
), meaning that the baked in resources
are unused in servoshell.

For 3rd-party embedders, we probably also want to the let them know
early that they should initialize the resources, instead of
restricting the panics to production mode.

Rippy is the only resource which was required. Since it is only
253 bytes large, we just bake that resource in as a fallback.

We do want to make using the resources easy from tests, so we add
some logic to keep the baked in resources for tests only and initialize
the resource reader on first access.

---
<!-- 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
- [ ] These changes fix #___ (GitHub issue number if applicable)
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-04-17 05:12:44 +00:00
webbeef
139774e6b5
Add an about:memory page (#35728)
This patch exposes a servo internal DOM API that is only made available to about:
pages on the navigator object to request memory reports. The about:memory page itself is
loaded like other html resources (eg. bad cert, net error) and makes use of this new API.

On the implementation side, notable changes:
- components/script/routed_promise.rs abstracts the setup used to fulfill a promise when the
  work needs to be routed through the constellation. The goal is to migrate other similar
  promise APIs in followup (eg. dom/webgpu/gpu.rs, bluetooth.rs).
- a new message is added to request a report from the memory reporter, and the memory reporter
  creates a json representation of the set of memory reports.
- the post-processing of memory reports is done in Javascript in the about-memory.html page,
  providing the same results as the current Rust code that outputs to stdout. We can decide
  later if we want to remove the current output.

Signed-off-by: webbeef <me@webbeef.org>
2025-03-07 05:25:08 +00:00
Martin Robinson
7256590599
Remove resources/prefs.json (#34999)
This file is not used any longer.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-01-16 07:38:58 +00:00
Martin Robinson
0e616e0c5d
api: Flatten and simplify Servo preferences (#34966)
Flatten and simplify Servo's preferences code. In addition, have both
preferences and options passed in as arguments to `Servo::new()` and
make sure not to use the globally set preferences in `servoshell` (as
much as possible now).

Instead of a complex procedural macro to generate preferences, just
expose a very simple derive macro that adds string based getters and
setters.

- All command-line parsing is moved to servoshell.
- There is no longer the concept of a missing preference.
- Preferences no longer have to be part of the resources bundle because
  they now have reasonable default values.
- servoshell specific preferences are no longer part of the preferences
  exposed by the Servo API.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-01-14 13:54:06 +00:00
Martin Robinson
93ae8d22fc
Correct a variety of documentation issues (#34786)
Fix some warnings in documentation as well as some faulty documentation
introduced in #34776.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-12-29 10:37:57 +00:00
Jonathan Schwender
fe58556c0b
Disable resources_for_tests in production (#34177)
Rather than relying on dead-code elimination to remove
the function in production builds, it is better if it is
never included in the first place.
On OpenHarmony we never want to include these files into the
binary, since we always bundle the test files into the `.hap` as part of the build process.
The original comment got the condition inverted and in all
normal builds the function will be checked as usual.
There shouldn't be any additional value in checking the
correctness of `resources_for_tests()` in production builds.

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
2024-11-08 12:02:47 +00:00
DK Liao
41fd39a128
doc(resources): Add documentation to undocumented embedder_traits::resources::Resource variants (#33885)
* Document Resource variants and update blocklist url

Signed-off-by: DK Liao <dklassic@gmail.com>

* Update components/shared/embedder/resources.rs

Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: DK Liao <dklassic@gmail.com>

* Update components/shared/embedder/resources.rs

Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: DK Liao <dklassic@gmail.com>

* Update components/shared/embedder/resources.rs

Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: DK Liao <dklassic@gmail.com>

* Update format and reduce length

Signed-off-by: DK Liao <dklassic@gmail.com>

* Slightly changes the line break position

Signed-off-by: DK Liao <dklassic@gmail.com>

---------

Signed-off-by: DK Liao <dklassic@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2024-10-18 03:44:14 +00:00
Ngo Iok Ui (Wu Yu Wei)
b58cee48ce
doc(resources): Preferences, HstsPreloadList, RippyPNG (#33775)
* Set to default if Preferences and HstsPreloadList are empty

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Add documentation of Preferences, HstsPreloadList, RippyPNG

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Add warn log when setting prefs to default

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Add error log instead

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Add error log to HSTS preload list

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Apply suggestions from code review

Address a couple wording nits

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

---------

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-10-10 18:19:41 +00:00
Hayashi Mikihiro
86c4e014b4
Replace the lazy_static crate with std::sync::LazyLock in components/shared (#33060)
* replace in pub_domains.rs

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

* replace in embedder/resources.rs

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

* replace in base/id.rs

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

* replace in net/lib.rs

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

* remove lazy_static from components/shared

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

---------

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2024-08-15 12:05:29 +00:00
Martin Robinson
7ea894774f
Add a directory listing feature for file URLs (#32580)
Signed-off-by: Bobulous <Bobulous@users.noreply.github.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Bobulous <Bobulous@users.noreply.github.com>
2024-06-26 08:02:50 +00:00
Martin Robinson
f4d3af296c Move *_traits and other shared types to shared
This is the start of the organization of types that are in their own
crates in order to break dependency cycles between other crates. The
idea here is that putting these packages into their own directory is the
first step toward cleaning them up. They have grown organically and it
is difficult to explain to new folks where to put new shared types. Many
of these crates contain more than traits or don't contain traits at all.

Notably, `script_traits` isn't touched because it is vendored from
Gecko. Eventually this will move to `third_party`.
2023-11-03 15:38:18 +00:00
Renamed from components/embedder_traits/resources.rs (Browse further)