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

[meta] embedding #30593

Open
18 of 39 tasks
delan opened this issue Oct 20, 2023 · 13 comments
Open
18 of 39 tasks

[meta] embedding #30593

delan opened this issue Oct 20, 2023 · 13 comments
Labels
B-meta This issue tracks the status of multiple, related pieces of work

Comments

@delan
Copy link
Member

delan commented Oct 20, 2023


@delan delan added the B-meta This issue tracks the status of multiple, related pieces of work label Oct 20, 2023
@fabricedesre
Copy link
Contributor

What's the benefit of going Rust -> C -> Rust ?

@mrobinson
Copy link
Member

What's the benefit of going Rust -> C -> Rust ?

The main benefit of this approach is the ability to ship a shared object.

@fabricedesre
Copy link
Contributor

But wry is already pure Rust so it doesn't need that, right?

@mrobinson
Copy link
Member

But wry is already pure Rust so it doesn't need that, right?

Since Servo takes so long to build, being able to ship a shared object version of Servo will make it easier for embedders to use it.

@wusyong
Copy link
Contributor

wusyong commented Oct 21, 2023

We are trying to update our entry method to use raw window handle recently.
Wry itself doesn't handle other things but wrap around webview instance only. I just need to make sure Servo and other related types can work. I'll try the approach similar to servoshell first and then explore multiwindow next.

A shared object isn't that urgent IMHO. Defining a C API that is ergonomic enough is another challenge as well. I tried to deal with CEF's C API before, and the experience didn't go that well. What I think is better are shared objects for huge C++ dependencies like mozangle and mozjs. These are always the first blocker in fresh environment. Maybe we could just download and link to built shared libraries if users only want to compile servo itself. Another benefit is developers can dive into servo codebase and hack it directly. I found I often need to refactor some servo code too.

@sagudev
Copy link
Member

sagudev commented Oct 31, 2023

Here is interesting blog post about dylib: https://robert.kra.hn/posts/2022-09-09-speeding-up-incremental-rust-compilation-with-dylibs/
I think something like that would be the best way for mozjs. mozangle is a bit more complicated on windows as we need it's produced dlls (libEGL.dll & libGLESv2.dll).

@delan
Copy link
Member Author

delan commented Oct 31, 2023

@sagudev interesting! I didn’t realise it was possible to build a lib crate as a dylib unless we used the C ABI. I wonder if it will break monomorphisation or break if type layout changes between runs.

@sagudev
Copy link
Member

sagudev commented Oct 31, 2023

Hm, I'm not entirely sure on stability of dylib, but thinking about it again maybe that's not the best way as we still need rust code generated by bindgen. We could just cache libmozjs static, but we might still need to run configure for bindgen so we cannot really eliminate it's build sys requirements.

@wusyong
Copy link
Contributor

wusyong commented Nov 7, 2023

@sagudev It's okay to still running bindgen for build script as long as there's a static lib like deno's v8 wrapper did IMHO. People usually have trouble with C++ building setup instead of rust. Does spider monkey published their binary release already?

@sagudev
Copy link
Member

sagudev commented Nov 7, 2023

@wusyong SpiderMonkey does offer prebuilds as artifacts on taskcluster, but we are patching SM in mozjs, so we would need to this for ourself. I have rough idea how this could work via automated CI jobs.

@wusyong
Copy link
Contributor

wusyong commented Nov 7, 2023

Btw I saw mozangle also has patches but it seems they are trivial. Maybe we can try to pull angle artifact and link it for mozangle's case.

@atbrakhi
Copy link
Member

atbrakhi commented Nov 7, 2023

Just an update on shared object for mozangle, we are able create shared object for mozangle using crate-type: dylib. It is working with servo on mac! Yet to test on windows though, it will be interesting!

We are also exploring possible cons of dylib and cdylib, please share if you have any thoughts/suggestions. Idea would be to have same approach for mozangle as well as mozjs

@wusyong
Copy link
Contributor

wusyong commented Nov 8, 2023

As long as the building process can be easier, I'm happy to see any attempt. I think the main concern for dylib is unstable Rust ABI. But right now servo also has to stick to certain nightly version anyway. So maybe this is not a big concern for developing purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-meta This issue tracks the status of multiple, related pieces of work
Projects
None yet
Development

No branches or pull requests

6 participants