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

[server] Remove the HTTP server (like in Bookari) #42

Open
jmgeffroy opened this issue Feb 7, 2022 · 4 comments
Open

[server] Remove the HTTP server (like in Bookari) #42

jmgeffroy opened this issue Feb 7, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@jmgeffroy
Copy link
Contributor

jmgeffroy commented Feb 7, 2022

Removing the HTTP server has a lot of positive consequences:

  • The contents is no longer accessible to other apps
  • Requests responses are no longer serialized, and this provides a huge boost in performances (99% of the time is spent in this serialization, according to recent profiling).

This performance boost can easily be perceived when navigating with the ToC or progressbar in a book which contains its own fonts, or many image assets. In this area:

  • Google Play Books, Kindle, Colibrio, Moon Reader, FB Reader and Bookari are extremely fast in this use-case. Most of them don't use the same technology as Readium and Iridium do (webviews+HTTP servers), however. But Bookari does rely on WebViews. Bookari only starts a HTTP server if the device is running Android < API level 24:
    • On android 4.x because the WebResource API did not exist
    • On Android 5 and 6 because audio files are not read
  • Readium, Iridium, and other Readium-based apps have strong performance issues there.

For Iridium, we don't need to take care of Android <= 6, but we'll maintain the ability to start the HTTP server for different usages, such as client-server deployments (some adaptations will be required for his use-case but are worth investigating).

Thanks to the migration to Flutter InAppWebView, we have everything we need:
https://pub.dev/documentation/flutter_inappwebview/latest/flutter_inappwebview/WebView/onLoadResourceCustomScheme.html

onLoadResourceCustomScheme is an InAppWebView cross-platform option, so it should be OK on both Android and iOS...

Note: See in Bookari (Mantano private repo)

  • EpubWebViewClient.shouldInterceptRequest
  • Epub3WebViewFragment.mustRunServer

See also:

@jmgeffroy jmgeffroy pinned this issue Feb 7, 2022
jmgeffroy added a commit that referenced this issue Feb 9, 2022
@jmgeffroy jmgeffroy added the enhancement New feature or request label Feb 10, 2022
yteitel added a commit that referenced this issue Feb 11, 2022
…r or android web resource (JS files does not work)
@jmgeffroy
Copy link
Contributor Author

First tests are disappointing from a performance point of view. The reason is that "you shouldn't do any heavy processing inside shouldInterceptRequest, as it is a synchronous call (albeit on another thread). Calls for all network requests are processed on the same thread so blocking for one request will cause all of the other requests to be blocked as well" (source).
So we should spawn isolates.

@jmgeffroy
Copy link
Contributor Author

Putting this on hold, and implementing isolates in the server version

@westernbuptboy
Copy link

note and bookmark not work on Android 6 because paginationInfo and currentSpineItemContext is null. related to this issue?

@gwangbaekun
Copy link

Yes. related. Bloc doesn't add data anymore. You should manually set paginationInfo with the position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants