shorebirdtech / shorebird

Code Push for Flutter and other tools for Flutter businesses.
https://shorebird.dev
Other
2.25k stars 133 forks source link

feat: web support #2357

Open iapicca opened 2 months ago

iapicca commented 2 months ago

Description

at the time of writing updating a flutter PWA is clumsy if possible at all, it would be great if shorebird would support flutter web allowing code push to flutters PWA

Requirements

current behavior

  1. deploy a counter app on netlify (or wherever)
  2. "add it to the screen" of a mobile device
  3. make some change in the app (color or whatever) and re-deploy
  4. open the app in the browser to confirm changes are present
  5. open the installed app (from the icon) and observe no changes

ideal behavior

  1. open the installed app and observe changes have taken place

Additional Context

bryanoltman commented 2 months ago

It looks like there are a few different issues at play here. Please correct me if I'm misunderstanding any of these.

  1. https://github.com/flutter/flutter/issues/105977 seems to suggest that the app itself is updated, but the home screen is not. I believe this would need to be fixed at the Flutter level—Shorebird would not be able to help with this.
  2. https://github.com/flutter/flutter/issues/104509 looks like a request for an "update is available" notification, not an update mechanism itself. Shorebird's API might be able to help with this, but I'm not sure that would be the right solution.

We haven't thought much about web support, as the web itself is an update delivery mechanism. What would you want Shorebird to do that the browser's refresh button doesn't?

iapicca commented 2 months ago
  1. [web] PWA apps do not update automatically flutter/flutter#105977 seems to suggest that the app itself is updated, but the home screen is not. I believe this would need to be fixed at the Flutter level—Shorebird would not be able to help with this.

@bryanoltman it could, but it's very unlikely to happen (not much going on in the PWA project) I understand that under-the-hood isn't necessarily code push, but as developer experience would feel very similar to shorebird for "native"

  1. Flutter web - Need documentation on how to conditionally display a "Refresh. New Version is available." prompt when updated code is deployed to production. flutter/flutter#104509 looks like a request for an "update is available" notification, not an update mechanism itself. Shorebird's API might be able to help with this, but I'm not sure that would be the right solution.

honestly I'm not sure why a "notification" for an "new version available" could not just trigger an update, I agree with you that the issue points at a workaround rather than a solution, nonetheless it stress the importance of this feature for developers

We haven't thought much about web support, as the web itself is an update delivery mechanism. What would you want Shorebird to do that the browser's refresh button doesn't?

that's the absurdity of the problem: a refresh button won't refresh a PWA it's easily reproducible:

eseidel commented 2 months ago

Would this help? https://stackoverflow.com/questions/70968547/pwa-how-to-refresh-content-every-time-the-app-is-opened

iapicca commented 2 months ago

Would this help? https://stackoverflow.com/questions/70968547/pwa-how-to-refresh-content-every-time-the-app-is-opened

I don't think it really apply to flutter's case and if it did, refreshing every time would be a pretty bad ux as pointed out in the comments

I understand this is a flutter issue, the reason why I'm posting this here is because what shorebird does for native would 100% fix the problem

on top of the arguments made above, please consider the use case in which a developer would have to split codebase shorebird for native and vanilla for web while building the same app (I already had a couple of native + web app)

not asking to rush it into the top of the priorities, just keep it in mind for future discussions

cedvdb commented 2 months ago

@iapicca

Is this issue to update the name and icon when a PWA is installed on a mobile device ? Or is it to update the actual code.

If it's the actual code, I believe that's already supported by the PWA technology. You'll see the updated version on next opening (and it should be the same for icon and name actually, so I'm not sure now).

iapicca commented 2 months ago

@cedvdb

Is this issue to update the name and icon when a PWA is installed on a mobile device ? Or is it to update the actual code.

the latter

If it's the actual code, I believe that's already supported by the PWA technology.

it should, but flutter doesn't support it

You'll see the updated version on next opening

in my experience it won't to reproduce simply (added to the initial post)

see reply

that's the absurdity of the problem: a refresh button won't refresh a PWA it's easily reproducible:

  • create and deploy a flutter web app
  • install as PWA
  • change and re-deploy the app

    • the new version of the web app is available in browser
    • the PWA is stuck on the old version even refreshing / open-close the PWA