Repository navigation
Revisit how the Android port works. - #20912
Conversation
| @@ -0,0 +1,3 @@ | |||
| This is a basic wrapper around Servo. While libservo itself (/components/servo/) offers a lot of flexibility, | |||
| libsimpleservo (/ports/libsimpleservo/) tries to make it easier to embed Servo, without much configuration needed. | |||
| It is limited to only one view (no tabs, no multiple renering area). | |||
There was a problem hiding this comment.
s/renering area/rendering areas/
jdm
left a comment
There was a problem hiding this comment.
This looks like a really useful improvement :D
| use std::path::Path; | ||
|
|
||
| fn main() { | ||
| println!("cargo:rerun-if-changed=build.rs"); |
There was a problem hiding this comment.
Note that if the build script itself (or one of its dependencies) changes, then it's rebuilt and rerun unconditionally, so cargo:rerun-if-changed=build.rs is almost always redundant (unless you want to ignore changes in all other files except for build.rs).
|
|
||
| struct ResourceReader(Box<ReadFileTrait>); | ||
| unsafe impl Send for ResourceReader {} | ||
| unsafe impl Sync for ResourceReader {} |
There was a problem hiding this comment.
This is scary. What if we store Box<ReadFileTrait + Send + Sync> instead?
|
Note to self:
|
|
WebVR build segfaults: |
|
@MortimerGoro I might need your help here. I get a crash in This PR changes how Servo runs on Android. Instead of using an empty Android app and load Servo via Glutin, we have a proper Android app that use a GLSurfaceView and load servo as a library and make some calls via JNI. I don't know what In the meantime, I will compile with my own version of rust-webvr see if I can find precisely where it crashes. @jdm / @MortimerGoro also, in general, do you know how to get a rust stack trace on Android when it crashes? |
|
@paulrouget I suspect that the crash is related to JNI calls which get the activity this way: android::get_app().activity Could you check that android::get_app() is not null && the activity has a correct value?. If not we'll need to implement a different way to get it or expose a method in rust-webvr to set it from servo. |
|
@paulrouget have you checked if WebGL works ok? IIRC GLSurfaceView was not a very friendly API to create shared contexts |
|
@MortimerGoro WebGL works. |
|
You were right. I'll try to figure out how to fix this. |
|
@MortimerGoro I don't use android rs glue. Should I? Does it even make sense for a library? If I don't, what's the alternative? We could add some embedder methods to access the activity. Would that be enough? |
|
I think that the best way would be to get rid of android-rs-glue, and pass the JNI JavaVM and Activity pointers to rust-webvr (e.g. in the constructor or initialization methods). |
|
To answer the question about stack traces, I do the following:
|
|
☔ The latest upstream changes (presumably #20421) made this pull request unmergeable. Please resolve the merge conflicts. |
Entirely? Looks like it's used extensively. |
|
@MortimerGoro what if I initialize the android glue manually |
I tried, but struggling. My approach is, in Java, get the application via: mApp = ((Activity) context).getApplication();
// mApp is not nullpassed to Rust: init(.., app: JObject, ..) {
unsafe {
android_injected_glue::ANDROID_APP = app.into_inner() as *mut android_injected_glue::ffi::android_app;
}
// get_app().activity crashes
} |
|
@bors-servo r- I’d prefer the argument escaping to be fixed before landing, but if you feel strongly this is better left to a follow-up feel free to r+ again. |
|
We are going to run into a timeout as we are waiting on a logcat message that will never arrive because the new port doesn't redirect stdout to logcat. There are few ways to do that:
Relevant: #19999 For now, I think the best thing to do is to use I'll look at this tomorrow. |
|
☔ The latest upstream changes (presumably #21250) made this pull request unmergeable. Please resolve the merge conflicts. |
|
I managed to solve the logcat issue, Edit: nope, issue on my side. |
|
@SimonSapin addressed your comments. Using JSON now. Can you please check the 2 last commits? Also, I made it so that |
|
@bors-servo r=jdm,mortimergoro,simonsapin |
1 similar comment
|
@bors-servo r=jdm,mortimergoro,simonsapin |
|
📌 Commit a923e8b has been approved by |
|
@bors-servo r=jdm,mortimergoro,simonsapin |
|
📌 Commit 6a31864 has been approved by |
|
☀️ Test successful - android, android-x86, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
|
This PR deleted occurrences of |
Likely. Can you file a dedicated issue for that? |

Fix #20855
Fix #18625
Fix #21147
Before polishing and making sure everything works fine (like the VR code, the android-x86 version, the non-android version of the lib, …), I'd like to get some early feedback on the approach.
I recommend reviewing commit by commit.
To test, just follow the regular steps:
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is