On 8 July 2017 at 00:20, Anton Lundin <[email protected]> wrote:
> On 07 July, 2017 - Lubomir I. Ivanov wrote:
>
>> On 7 July 2017 at 23:47, Linus Torvalds <[email protected]> 
>> wrote:
>> > On Fri, Jul 7, 2017 at 1:41 PM, Lubomir I. Ivanov <[email protected]> 
>> > wrote:
>> >>
>> >> it appears that caching google maps tiles violates the google maps
>> >> (free / public) usage rules.
>> >
>> > I read that as "you can cache for performance" reasons. Bad networking
>> > is a *big* performance reason.
>> >
>> > You can't use the map data for anything else, or index it in any other
>> > way. But that's ok, we don't do that.
>> >
>>
>> ok, i guess i'm going to test this html5 caching feature to see if it works:
>> https://stackoverflow.com/a/13334284
>>
>> right now what happens is that the tiles are downloaded and cached,
>> but once the internet connection drops, zooming in and out does not
>> re-display the previously downloaded tiles.
>> also to my understanding this caching might be limited per session,
>> unless this is implemented:
>> http://doc.qt.io/qt-4.8/qwebsettings.html#setOfflineWebApplicationCachePath
>>
>> will try to test the above solutions during the weekend.
>
> Cache manifests (or the whole manifest thingie for that) is a nightmare
> to work with and debug, so I suggest using a serviceworker instead.
>

i realized that cache manifests do not support wildcards and the
manifest cannot possibly cover all the google maps tile URLs.

> A quick search found me https://github.com/boopathi/sw-demo-iss
>

in the above page it says:

"Pending:
[ ] Haven't figured a way to cache Google Maps API results using
Service Workers."

i'm not sure if the tile fetching falls under the above scope, but i
think it does.
so if the above guy hasn't been able to do it, maybe it's just way too tricky.

can't find a single clear example online in the lines of "OK, here is
how you cache google maps tiles using service workers".

but also, service workers do not work with file:/, qrc:/ paths, so
they seem to require either a localhost HTTP server to be running or
in case of a remote connection a HTTPS.
so to my understanding we need to make Subsurface create a HTTP server
on localhost (on a free port), load all resources like index.html,
service-worker.js, etc from Qt resources and then the server needs to
return the contents of these files when the QWebView opens
http://localhost:<port>/index.html.

from that point on we go back to the thing the github person mentions:
"[ ] Haven't figured a way to cache Google Maps API results using
Service Workers."

> We could probably hook into WebKit / Webengine and cache the requests
> our self. I haven't looked at the apis yet, but one can do such things
> in the android webview and I guess the api's have some sort of feature
> parity.
>

yes, i have a feeling the fetching / caching has to be done on the C++ front.
https://stackoverflow.com/a/4588113
https://stackoverflow.com/questions/20616064/qwebview-caching

^ each QWebPage can have a custom QNetworkAccessManager which can
override requests or dispatch singnals when a QNetworkRequest has
finished, which is pretty much a can cover the "fetch" listeners (in
service-worker terminology). in the createRequest() override. so it
seems possible.

but another gotcha is that QNetworkAccesManager is non-portable to QWebEngine.
https://stackoverflow.com/a/38221276

lubomir
--
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to