Skip to content

Dependency on /resources/ #15635

Open

Description

@paulrouget

This issue is part of an effort to improve Servo's embedding story. See https://github.com/paulrouget/servoshell/projects/2

Using libservo in another project requires copying the /resources/ directory into the embedder source code. Would it be possible to "include" these files within the libservo library?

Activity

  1. paulrouget commented on Apr 29, 2017

    @paulrouget
    ContributorAuthor
  2. metajack commented on May 2, 2017

    @metajack
    Collaborator

    We could certainly include them at compile time wth include_str! and include_bytes!. We'd probably only want to do this in library form in external apps, or alternatively do it always but have some runtime flag that gives it a place to look to override these.

  3. metajack commented on May 2, 2017

    @metajack
    Collaborator

    We'd probably need some kind of file loader module that the code that reads these uses, which can do the right thing.

  4. paulrouget commented on May 30, 2017

    @paulrouget
    ContributorAuthor

    If we manage to only keep the necessary resources, we would move 3.1Mb of strings to 880Kb.

  5. tschneidereit commented on Jun 26, 2017

    @tschneidereit
    Contributor

    @metajack let's talk about what to do here this week.

  6. nox commented on Oct 8, 2017

    @nox
    Contributor

    @tschneidereit @paulrouget Did you ever decide what's the way to go for this?

  7. paulrouget commented on Oct 8, 2017

    @paulrouget
    ContributorAuthor

    Yes. As soon as I have some time, I'll finish my PR #17769. The idea is first to only keep what's absolutely necessary (many stuff in /resources/ are useless at runtime), then bundle the files with the library (what Jack said).

  8. paulrouget commented on Mar 23, 2018

    @paulrouget
    ContributorAuthor
  9. jdm commented on Mar 23, 2018

    @jdm
    Member

    This is a code sample to get an x509 from a buffer, too.

  10. paulrouget commented on Mar 28, 2018

    @paulrouget
    ContributorAuthor

    I'm working on delegating resources reading to the embedder.

    The resources files are read from:

    • image cache: rippy.png
    • hsts: hsts_preload.json and certs, in new_resource_threads when the constellation is created
    • bluetooth: gatt_blocklist.txt, static
    • dom/servoparser: badcert.html and neterror.html, to display a network error
    • userscripts
    • prefs.json: static
    • net_traits/pub_domains.rs: public_domains.txt
    • WR: shaders

    I'm introducing an embedder message:

    • ReadChromeUrl(ServoUrl, IpcSender<Result<Vec>, String /Error Message/>);

    I also implemented a chrome_loader that resolve and read a chrome://resource url.

    So all the components above need to either have access to, either, the EmbedderProxy or a way to make Fetch call to a chrome url.

    • prefs.json: static
    • bluetooth: gatt_blocklist.txt, static
    • hsts: hsts_preload.json and certs, in new_resource_threads when the constellation is created
    • net_traits/pub_domains.rs: static, public_domains.txt

    For these, because it's done during initialization of Servo, we can pass a Chrome URL resolver/reader to Servo. It should not be too hard.

    • userscripts

    For this one, we can just let Servo read the files itself, without the help of the embedder.

    • WR: shaders

    Apparently, they are compiled within WR now. So same as userscripts

    The problematic components are:

    • image cache: rippy.png
    • dom/servoparser: badcert.html and neterror.html, to display a network error

    Here, I don't know how to reach back to the embedder or the constellation or call a Fetch on the chrome url. Could we use some sort of redirect mechanism?

  11. jdm commented on Mar 28, 2018

    @jdm
    Member

    @paulrouget I see two possible solutions here:

    1. make the part of the Fetch algorithm that is responsible for processing response headers synchronous, so that FetchResponseListener::process_response could return an enum that means "I am ready to accept the body" or "please redirect transparently to [url]". This would also require that the Metadata structure contains some way of obtaining the pre-redirect URL, so that consumers of the redirected response would be able to transparently report the pretend URL as necessary. This would allow ServoDomParser::process_response to return chrome URLs for the error cases that it wants to be responsible for handling.
    2. Make ScriptThread::handle_page_headers_available accept a Result argument for the page metadata, then abort the current load and initiate a new load for the appropriate chrome URL if an error is encountered.

    Option 2 looks more contained to me, and will not impact the performance of non-error loads.

  12. added 3 commits that reference this issue on Apr 21, 2018
    7ced433
    c28d6f0
    d1378d6
  13. paulrouget commented on Apr 28, 2018

    @paulrouget
    ContributorAuthor

    So, this is still relevant. We made it so that the embedder can provide its own way of reading the files, but the files are still necessary. We still need to copy the resources/ directory into the embedder project.

    Keeping open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions