Skip to content

Offline support #11

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

Closed
rektide opened this issue Oct 24, 2016 · 5 comments
Closed

Offline support #11

rektide opened this issue Oct 24, 2016 · 5 comments

Comments

@rektide
Copy link

rektide commented Oct 24, 2016

Hiya! This is a pretty complicated ask, but I'd like to see offline support added to enrich this great capability.

From within a user-agent, if an origin has a foreign-fetch worker installed, other origins can- even while offline- issue requests and the foreign fetch handler has an opportunity to serve that request.

It would be very interesting and powerful if the user-agent could externalize this servicing: when a "Gallery" application goes to open a photo url, if the OS could proxy that request through the user-agent such the user agent could try to use it's foreign-fetch handler, then it could be possible for Gallery to open a photo even though the device is disconnected.

Also, without some kind of integration with foreign fetch, the Gallery app will always have to redownload the image, even though the user agent may have it cached, & that could be a considerably large download.

@terales
Copy link

terales commented Oct 27, 2016

Maybe for such scenario it's better to share image as Blob #7?

With such approach there is no need to change anything on the OS side, but only in the browser. Browser can execute request to get mime-type and if it's applicable then share binary content.

@rektide
Copy link
Author

rektide commented Nov 1, 2016

@terales using blob URL's sounds like a solid web platform capability to me, but by not sharing URLs you have no ability to meaningfully talk to 3rd parties about whatever it is you the target have been sent. That makes sharing blob URL dangerously anti-web in my view. I've commented more directly in #7. It's a good idea and would offer a direct path to better offline support, but I'd much rather see something that integrates well with the web and it's growing offline capabilities.

@mgiuca
Copy link
Collaborator

mgiuca commented Nov 2, 2016

So to clarify what you're requesting: when a native app receives a shared URL, it then fetches the URL and that fetch gets proxied through the user agent's service worker (allowing for URLs to be fetched while offline)?

That sounds cool, but I think "pretty complicated" is an understatement. This isn't really a feature request of Web Share, but a feature request for operating systems. All of them would need to change their URL fetch mechanism to proxy through the browser, or provide a new API for doing so. I think that's quite outside the realm of possibility, and certainly outside of the scope of Web Share.

I agree with terales@; I think sending blob data instead of URLs is the offline story for Web Share. And I will respond to your objections on #7.

@mgiuca mgiuca closed this as completed Nov 2, 2016
@rektide
Copy link
Author

rektide commented Nov 3, 2016

This isn't really a feature request of Web Share, but a feature request for operating systems. All of them would need to change their URL fetch mechanism to proxy through the browser, or provide a new API for doing so.

Whoa whoa, what??? No no no no. That sounds truly mad.

First off, there are established HTTP proxy protocols. The browser need only implement one of those.

Historically the HTTP_PROXY environment variable is all that's required to point most applications to a proxy! That could be set in the environment variables for any system wanting to use a proxy the browser provides. A browser could try to install this into the system envs if desired.

What the browser would have to provide is a proxy implementation that A) looks for the resource in foreign fetch Service Workers & tries to reply with those and B) passes all remaining requests through to the OS. This is non-trivial, but also doable.

This could perhaps even be implementable as a website + local proxy daemon on the device, without needing browser support at all. It'd be complex and scary devising some transport to funnel requests- a ServiceWorker using long running Fetch requests against a local proxy daemon, which funnels requests to the ServiceWorker who then runs a new Fetch for that requests & funnels it back down & out. Hopefully such antics need not be considered and this issue can be reopened here or in some other venue in the future. Maybe needs it's own WICG perhaps, and for this spec to perhaps maybe mention this.

@mgiuca
Copy link
Collaborator

mgiuca commented Nov 4, 2016

Sure, there are mechanisms for setting an application as a proxy in an operating system. Above all other concerns, this is absolutely outside of the scope of Web Share. You are essentially proposing a new web platform feature (or perhaps browser feature?), which is that a web browser should:

  1. Register itself as a proxy by which all HTTP requests throughout the system are fed.
  2. When an HTTP request comes in through the OS, pass that request through any matching service worker fetch handler.

Off the top of my head (without giving much serious consideration), here are some concerns with this proposal:

  • Different operating systems have different proxy mechanisms. It's unclear whether all HTTP requests (from any app) would go through these proxies. What about apps that provide their own HTTP implementation on top of the TCP stack?
  • Some operating systems would likely not allow arbitrary HTTP proxying.
  • You don't set a proxy app, but a proxy server. Therefore, the browser would have to be running a TCP server on localhost to receive and proxy all HTTP requests from the system.
  • The browser would have to assert itself as the HTTP proxy for the entire operating system. That raises security and privacy concerns (essentially by installing a browser it would automatically put some pretty deep hooks into the OS).
  • Would the user be able to decline to install the browser as the proxy? This would break stuff depending on this feature.
  • What would it mean if you have two browsers installed? Only one can be the proxy. What if you shared a URL (pointing at a URL accessible from your service worker) from one browser but the other browser is the system proxy?

This sounds like an incredibly complex solution in search of a problem (considering we can have offline support for Web Share by simply passing a blob object as I was originally intending).

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

No branches or pull requests

3 participants