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

~20 seconds startup time on Android because CSS Layout & libfontconfig #16195

Closed
MortimerGoro opened this issue Mar 30, 2017 · 1 comment
Closed

Comments

@MortimerGoro
Copy link
Contributor

@MortimerGoro MortimerGoro commented Mar 30, 2017

Hello,

I found that Servo on Android takes a lot of time to show anything on screen in most pages because CSS layout operations wait for libfontconfig initialization, which takes about 20 seconds (tested on Google Pixel). The problem seems to be that libfontconfig tries to read all system fonts on the FcInit method, and that takes a lot of time. This is done on every startup, the cache doesn't seem to work. Even if we can fix the cache, 20 seconds is a huge time for the first startup and it could ruin the initial impression for users when running servo. I also experienced some startup problems in the past on Windows, it might be related to this problem too.

On other platforms fontconfig caches can be prebuilt on the installation scripts, but this can't be done on Android with plain apks.

Some ideas to fix the issue:

  • Modify libfontconfig and filter the scanned font's on startup on Android. Only load the default ones used here:
    append_map(&mut generic_fonts, FontFamily::Generic(atom!("serif")), "Times New Roman");
  • Don't block CSS layout when libconfig is not initialized and relayout when libfontconfig is ready
  • I think that firefox uses libfontconfig on Android. At least a grep of the FF source shows that lib fontconfig is used by the cairo library. Maybe they had this issue too, we can research what they did.

What do you think?

@jdm
Copy link
Member

@jdm jdm commented Mar 30, 2017

This sounds like the same issue described in #12931, and #12931 (comment) described a particular reason why the cache wasn't working.

@MortimerGoro MortimerGoro mentioned this issue Jun 2, 2017
3 of 5 tasks complete
bors-servo added a commit that referenced this issue Jun 6, 2017
Ged rid of libfontconfig in Android

Libfontconfig dependency is causing huge startup times in Android (20 seconds on each page load!). On other platforms fontconfig caches are already available or can be prebuilt on installation scripts, but this can't be done on Android. Updating libfontconfig dependency doesn't fix the problem either.

This PR gets rid of libfontconfig in Android. It queries available fonts and variations from Android System font configuration files. Android doesn't provide an API to query system fonts until Android O (which is very far from the minimum API right now...)

---
<!-- 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 #16195 (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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/17141)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.