imslp / capacitor.geckoview

Capacitor with Geckoview
MIT License
5 stars 2 forks source link

Capacitor 6 support and beyond #1

Open nicobao opened 3 months ago

nicobao commented 3 months ago

Hi,

Thanks for your work. I would like to help you continue this work, whenever I have more time. However I don't understand exactly what changed and what didn't compared to @capacitor/android. I suppose you forked the official @capacitor/android and made small changes to use GeckoView instead of the system WebView? Which parts exactly? I would love if we could maintain a third party @imslp/capacitor-android-geckoview plugin? To be used as a replacement in any existing Capacitor apps, without plugin users to need extra knowledge. Btw I'm a bit confused as to why this repo also embeds example of how to use SQLite? Is the new WebView affecting this in any way?

What did you mean by this TODO? Which features are lacking?

Complete implementation of unimplemented features.

Also stumbled upon this alternative plugin: https://im.not.ci/capacitor-geckoview/

It mentions some specific quirks they had to go through. Have you faced them as well?

Changes at the Android level

Replacement of WebView: Literally replacing the system's WebView with GeckoView. Replacement of web file requests: Unlike the built-in WebView of Android and iOS's WebView, GeckoView itself cannot create a virtual file protocol or intercept file transmission. So we did some dirty work by directly opening an HTTP server on a random port for the WebView to access. Injection of communication functions: Rebound the communication protocol between the plugins and the web container. Essentially, post messages are still flying back and forth, nothing special.

Modifications inside the web container

Implementing a plugin to inject scripts: Since GeckoView does not support direct script injection into pages (of course, other browsers do support this¯(ツ)/¯), Hyper wrote a Firefox plugin to handle this issue separately. Initialization timing issue between plugins and web content: We found that plugin loading is always slower than web content, which could cause early communication to be lost. For this, we modified the communication bridge in Ionic, creating a queue to cache all communications until the plugin is loaded and then send them all at once. Data synchronization on random ports: Since the ports are random, there will inevitably be issues with cross-domain, localStorage synchronization, etc. This part is also handled with a little tweak at the plugin level.

Their plugin do not appear to be open source though, or at least I can't find the source code.

Cheers!

Losses commented 1 month ago

Hi,

Thank you for reaching out and for your interest.

It is unfortunate that this repository essentially appropriated our previous work and removed the names of our team members, and it has not been updated or maintained since. We did an update to upgrade Ionic to version 5 about half a year ago, but no one has had the energy to complete the latest version. However, a team recently contacted us offering some help, so there might be some follow-up information.

The repository that is currently being maintained is: https://github.com/Web-Media-Foundation/infrastructure/tree/master/packages/capacitor-geckoview

The latest update to ionic 5 can be found here: https://github.com/Web-Media-Foundation/infrastructure/commit/099c6eee42f37db03b995efb9c41a20df737ff48

The link you provided (im.not.ci) is my personal blog. If you need anything, feel free to contact us at Web-Media-Foundation/infrastructure.