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

Support building for Magic Leap. #21985

Merged
merged 1 commit into from Oct 29, 2018
Merged

Conversation

asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Oct 19, 2018

This PR gets Servo to build for Magic Leap, and provides a dummy Servo2D app.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes do not require tests because it's a port to a new architecture

This change is Reviewable

@highfive
Copy link

Heads up! This PR modifies the following files:

@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify gfx and script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 19, 2018
@asajeffrey
Copy link
Member Author

It depends on servo/mozjs#158 and servo/media#158.

@asajeffrey
Copy link
Member Author

Filed #21999 to get servo-media updated.

@asajeffrey asajeffrey added the S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged. label Oct 22, 2018
@jdm jdm assigned jdm and unassigned emilio Oct 22, 2018
libservo = { path = "../../components/servo" }
servo-egl = "0.2"
log = "0.4"
smallvec = "0.6"
Copy link
Member

Choose a reason for hiding this comment

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

nit: let's start this in alphabetic order at least.

screen_avail: TypedSize2D::new(500, 500),
window: (TypedSize2D::new(500, 500), TypedPoint2D::new(0, 0)),
framebuffer: TypedSize2D::new(500, 500),
viewport: TypedRect::new(TypedPoint2D::new(0, 0), TypedSize2D::new(500, 500)),
Copy link
Member

Choose a reason for hiding this comment

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

nit: weird indentation.

fn get_coordinates(&self) -> EmbedderCoordinates {
EmbedderCoordinates {
hidpi_factor: TypedScale::new(1.0),
screen: TypedSize2D::new(500, 500),
Copy link
Member

Choose a reason for hiding this comment

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

Shall we move these magic numbers into constants at least?

Resource::QuirksModeCSS => &include_bytes!("../../../resources/quirks-mode.css")[..],
Resource::RippyPNG => &include_bytes!("../../../resources/rippy.png")[..],
Resource::DomainList => &include_bytes!("../../../resources/public_domains.txt")[..],
Resource::BluetoothBlocklist => &include_bytes!("../../../resources/gatt_blocklist.txt")[..],
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth adding a build script to this crate that forces a rebuild if any of these files are modified?


impl log::Log for MLLogger {
fn enabled(&self, metadata: &log::Metadata) -> bool {
metadata.level() <= log::Level::Info
Copy link
Member

Choose a reason for hiding this comment

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

Maybe store the level in a constant so the set_max_level call earlier matches?


// The prism dimensions
const glm::vec3 Servo2D::getInitialPrismExtents() const {
return glm::vec3(0.5f, 0.5f, 0.5f);
Copy link
Member

Choose a reason for hiding this comment

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

Do these relate to the 500s in libmlservo, or is that just coincidence?

lumin::ui::Cursor::SetScale(prism_, 0.03f);
instanceInitialScenes();

// Get the panar resource that holds the EGL context
Copy link
Member

Choose a reason for hiding this comment

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

panar?

EGLSurface surf = plane_->getEGLSurface();
EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglMakeCurrent(dpy, surf, surf, ctx);
glViewport(0, 0, 500, 500);
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to match the 500s in libmlservo? Can we pass this value in to Rust?

int main(int argc, char **argv)
{
ML_LOG(Debug, "Servo2D Starting.");
Servo2D myApp;
Copy link
Member

Choose a reason for hiding this comment

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

Does argv contain meaningful values for us? Can we accept a URL on the command line?

EGLSurface surf = plane_->getEGLSurface();
EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglMakeCurrent(dpy, surf, surf, ctx);
glViewport(0, 0, 500, 500);
Copy link
Member

Choose a reason for hiding this comment

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

Let's make this a named constant somewhere.

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Oct 22, 2018
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #20755) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added S-needs-rebase There are merge conflict errors. S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Oct 23, 2018
@asajeffrey
Copy link
Member Author

I did some fixes, but can't test the C++ code because I'm at home rather than in the office.

@asajeffrey
Copy link
Member Author

Rebased.

@asajeffrey asajeffrey changed the title [WIP] Support building for Magic Leap. Support building for Magic Leap. Oct 23, 2018
@asajeffrey asajeffrey removed the S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged. label Oct 23, 2018
@asajeffrey
Copy link
Member Author

Updated mozjs_sys which was the last external blocker.

@paulrouget
Copy link
Contributor

I see that you introduced a new port. Did you consider using the c api of libsimpleservo instead of libmlservo?

@asajeffrey
Copy link
Member Author

@paulrouget yes, originally I was using libsimpleservo but ran into horrible linking problems which went away if I used libservo directly. My suspicion is that the ML is going to be a different enough target from Android that we're going to need a different port at some point anyway.

@paulrouget
Copy link
Contributor

libsimpleservo can be compiled without any android stuff (it compiles on Desktop for example). It's supposed to be capable of being dynamically loaded like libservo. I'd be interested to know what kind of issues you ran into.

I don't want to block this, but maybe later we could look at how to re-use libsimpleservo for ML.

@asajeffrey
Copy link
Member Author

It's been a while, but there was some issue about libsimpleservo being dynamically loaded causing symbols not to be found. I may have fixed that in the mean time, e.g. by statically loading openssl.


## Building the Servo2D application

From inside the `ports/magicleap/Servo2D` directory:
Copy link
Contributor

Choose a reason for hiding this comment

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

s/ports/support

@jdm
Copy link
Member

jdm commented Oct 29, 2018

@bors-servo delegate+
I'm fine with keeping the question about the URL as a followup.

@bors-servo
Copy link
Contributor

✌️ @asajeffrey can now approve this pull request

@asajeffrey
Copy link
Member Author

@bors-servo r=jdm

@bors-servo
Copy link
Contributor

📌 Commit dab8f4a has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors. labels Oct 29, 2018
bors-servo pushed a commit that referenced this pull request Oct 29, 2018
Support building for Magic Leap.

<!-- Please describe your changes on the following line: -->

This PR gets Servo to build for Magic Leap, and provides a dummy Servo2D app.

---
<!-- 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
- [X] These changes do not require tests because it's a port to a new architecture

<!-- 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. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21985)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

⌛ Testing commit dab8f4a with merge 0ec0f70...

@bors-servo
Copy link
Contributor

@bors-servo bors-servo merged commit dab8f4a into servo:master Oct 29, 2018
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Oct 29, 2018
@asajeffrey asajeffrey mentioned this pull request Oct 29, 2018
5 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.

None yet

7 participants