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

Feat: Deploy Flutter Web App to GitHub Pages #322

Closed
2 tasks done
nelsonic opened this issue Mar 2, 2023 · 29 comments · Fixed by #323
Closed
2 tasks done

Feat: Deploy Flutter Web App to GitHub Pages #322

nelsonic opened this issue Mar 2, 2023 · 29 comments · Fixed by #323
Assignees
Labels
discuss Share your constructive thoughts on how to make progress with this issue enhancement New feature or enhancement of existing functionality flutter Flutter related issues help wanted If you can help make progress with this issue, please comment! in-progress An issue or pull request that is being worked on by the assigned person priority-1 Highest priority issue. This is costing us money every minute that passes. research Research required; be specific T2h Time Estimate 2 Hours tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

nelsonic commented Mar 2, 2023

As noted in #316 (comment) and #315 (comment) 💬
deploying the Flutter Web App to Fly.io has proved to be a performance fail. 😕

As noted by @LuchoTurtle in #315 (comment)
it should be possible to get a 90+ PageSpeed (LightHouse) performance score for a Flutter Web App ... 💭
However I've not been able to replicate the results on the PageSpeed Insights site:
https://pagespeed.web.dev/report?url=https%3A%2F%2Fdit-tests.web.app
So that's something we need to understand first. 🔍
How do we ensure that the PageSpeed results are consistent?
Can we run the tests as a GitHub Action and save the results somewhere we can review them? 🤔

Todo

This looks like a decent starting point:

Why This Matters?

Why are we making such an effort on page load time instead of focussing on building our App? 🤷‍♂️
I don't see this as "not building the app"; DevOps is about delivering the App. 🍕
Rather I see this is as complying with the first point on our Manifesto. 📜
If we invest weeks of our Dev time in building features 🧑‍💻 ⏳
and then the App takes ages to load for people viewing it for the first time, 🐌
it gives them a terrible first impression. 😢

I'm very happy to pick this up myself. ⏳
But if anyone else wants to help, it's much appreciated. 🙏

@nelsonic nelsonic added enhancement New feature or enhancement of existing functionality discuss Share your constructive thoughts on how to make progress with this issue priority-1 Highest priority issue. This is costing us money every minute that passes. technical A technical issue that requires understanding of the code, infrastructure or dependencies T2h Time Estimate 2 Hours research Research required; be specific tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written labels Mar 2, 2023
@LuchoTurtle
Copy link
Member

Should a different repo be created for this? Or should we create another workflow in this one?

@nelsonic
Copy link
Member Author

nelsonic commented Mar 2, 2023

@LuchoTurtle good question. 👌
Strong preference for using this repo and creating a new GitHub Actions Workflow
Typically the way we have done GitHub Pages deployment in other projects
is with a gh-pages branch that and a workflow to build the static content e.g:

Fairly certain you can use this action: https://github.com/JamesIves/github-pages-deploy-action (we're already using it)
to some of the boring bits. 💭

Please let me know if you want to pair on this. 👥 🧑‍💻
And if you want to spend a couple of hours on documenting what you learned, 🙏
please do so in: https://github.com/dwyl/learn-github-pages |> dwyl/learn-github-pages#2 📝

@nelsonic
Copy link
Member Author

nelsonic commented Mar 2, 2023

Capturing the BEFORE pictures for reference 📷
so that we can evaluate how much faster having the Flutter Web App 📱
is on GitHub Pages than on Fly.io 🏎️ vs. 🐌 ... 🤷‍♂️

Running Lighthouse in the Chrome Dev Tools is basically "Perfect Conditions":
pagespeed-insights-dwylapp-fly io-80-chrome-dev-tools

A far more realistic test is running it online:
https://pagespeed.web.dev/report?url=https%3A%2F%2Fdwylapp.fly.dev
pagespeed-insights-online-63-perf

For reference the dwyl.com static site is hosted on GitHub Pages and currently gets a 93 perf score:
https://pagespeed.web.dev/report?url=https%3A%2F%2Fdwyl.com
image

This should be our lower bound. i.e. if we go lower than this for the app we need to rethink things.
Ideally we should spend as much time as needed to get it up to 100.
Yes, it may feel like an "arbitrary" goal, but if we achieve 100 for everything it means we aren't wasting people's time. 👌

@nelsonic nelsonic added in-progress An issue or pull request that is being worked on by the assigned person help wanted If you can help make progress with this issue, please comment! flutter Flutter related issues labels Mar 2, 2023
@LuchoTurtle
Copy link
Member

Will work on this 👍

Though I feel the need to point out that comparing a Flutter Web app with dwyl.com is not necessarily a fair comparison, as the latter was made with JS + Tachyons and we already know the shortcomings of using Flutter Web.

Though this doesn't mean we shouldn't strive to go for near-native performance on all fronts 👍

@LuchoTurtle
Copy link
Member

I'm stumped on why Github Pages don't properly serve the built files from Flutter Web.

When I run python -m http.server locally, after running the exact same command from the workflow (flutter build web --release --web-renderer html), it shows the web app correctly..

LuchoTurtle added a commit that referenced this issue Mar 2, 2023
LuchoTurtle added a commit that referenced this issue Mar 2, 2023
@nelsonic
Copy link
Member Author

nelsonic commented Mar 2, 2023

@LuchoTurtle yes, the hand-crafted dwyl.com is significantly smaller
than even a "Hello World!" (counter) Flutter App ...
it's not meant to be comparison, just a reference.
GitHub Pages is already working well for us. ✅

But ... we need to do everything we can to get performance up to 100 on the Flutter Web App.
Even if we have to use "smoke and mirrors" ...
i.e. get creative with a "fake door" that only starts loading the Flutter App
after the page is fully interactive.

@nelsonic
Copy link
Member Author

nelsonic commented Mar 2, 2023

@LuchoTurtle it's a good sign that it works on localhost. 👌
The necessary files appear to be there on the gh-pages branch: https://github.com/dwyl/app/tree/gh-pages

image

The config for GitHub Pages appears to be correct.
https://github.com/dwyl/app/settings/pages
image

The fact that the index.html loads suggests that something is working. 🎉
Guessing you've done a bunch of googling ... 🔍
Please share links to what you've looked at. 🔗

@LuchoTurtle
Copy link
Member

The _flutter undefined error seems to be people trying to serve the web folder instead of build/web.
I'm doing so with the github-pages-deploy-action in the folder param.

      - name: Deploy to Github Pages
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          branch: gh-pages # The branch the action should deploy to.
          folder: ./build/web # The folder the action should deploy.

And I'm sure the folder exists because it's shown in the workflow.

image

I've checked many links, including the ones below.

But this seems like Github Pages is not serving the files correctly. Because flutter.js definitely exists in the workflow, so it shouldn't be undefined.

@nelsonic
Copy link
Member Author

nelsonic commented Mar 2, 2023

Could you try pushing everything to the branch
and then selecting ./build/web in the pages config: https://github.com/dwyl/app/settings/pages ?

@LuchoTurtle
Copy link
Member

LuchoTurtle commented Mar 2, 2023

You can't do that in the page config
image

they only allow root or under docs.

The source branch can be any branch in your repository, and the source folder can either be the root of the repository (/) on the source branch or a /docs folder on the source branch.

@LuchoTurtle
Copy link
Member

LuchoTurtle commented Mar 2, 2023

As per https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages#static-site-generators, they use Jekyll to serve the files. Perhaps customizing this behaviour might be a solution.

LuchoTurtle added a commit that referenced this issue Mar 2, 2023
@nelsonic
Copy link
Member Author

nelsonic commented Mar 2, 2023

A bit of Googling suggests a more targeted approach: https://github.com/bluefireteam/flutter-gh-pages 🤞

@nelsonic
Copy link
Member Author

nelsonic commented Mar 2, 2023

https://dwyl.github.io/app
error-with-permissions-policy

Is this error worth investigating?

Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'interest-cohort'.

@LuchoTurtle
Copy link
Member

A bit of Googling suggests a more targeted approach: bluefireteam/flutter-gh-pages 🤞

I guess I'll give this a whirl.

Is this error worth investigating?

Apparently not -> https://stackoverflow.com/questions/69619035/error-with-permissions-policy-header-unrecognized-feature-interest-cohort

@LuchoTurtle
Copy link
Member

LuchoTurtle commented Mar 2, 2023

Tried using bluefireteam/flutter-gh-pages but it's still not working. The same error appears...

Uncaught ReferenceError: _flutter is not defined
    at (index):42:7

I'll revert the changes and try to use .nojekyll file.

@LuchoTurtle
Copy link
Member

LuchoTurtle commented Mar 2, 2023

Maybe .nojekyll won't make a difference, as per https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/.

This should only be necessary if your site uses files or directories that start with underscores since Jekyll considers these to be special resources and does not copy them to the final site.

@nelsonic
Copy link
Member Author

nelsonic commented Mar 2, 2023

Hmm ... this is very peculiar.

@LuchoTurtle
Copy link
Member

@LuchoTurtle
Copy link
Member

LuchoTurtle commented Mar 2, 2023

Going to populate https://github.com/dwyl/learn-github-pages now.

LuchoTurtle added a commit that referenced this issue Mar 2, 2023
@nelsonic
Copy link
Member Author

nelsonic commented Mar 2, 2023

Re-opening just to configure Cloudflare subdomain 👨‍💻 ⏳

@nelsonic nelsonic reopened this Mar 2, 2023
@nelsonic
Copy link
Member Author

nelsonic commented Mar 2, 2023

loading ... https://dash.cloudflare.com/login?lang=en-US
image

@nelsonic
Copy link
Member Author

nelsonic commented Mar 2, 2023

https://github.com/dwyl/app/settings/pages
image

https://app.dwyl.com
image

Viewing the app at: https://app.dwyl.com/
image

@LuchoTurtle we're back to having the 404 on the logo and other files.
So looks like we need to update some config again. 🙏

@nelsonic
Copy link
Member Author

nelsonic commented Mar 4, 2023

https://app.dwyl.com is working thanks to #324 thanks for reviewing+merging @LuchoTurtle
image

@nelsonic nelsonic closed this as completed Mar 4, 2023
@nelsonic
Copy link
Member Author

nelsonic commented Mar 4, 2023

@nelsonic
Copy link
Member Author

nelsonic commented Mar 4, 2023

@nelsonic
Copy link
Member Author

nelsonic commented Mar 4, 2023

image

image

image

image

Deployment worked without any issues: https://app-abz.pages.dev/#/
image

No improvement in perf:
https://pagespeed.web.dev/report?url=https%3A%2F%2Fapp-abz.pages.dev%2F
image

So I don't think it's worth pursuing this further (for now ...) 💭

@nelsonic
Copy link
Member Author

nelsonic commented Mar 5, 2023

Disabled the Cloudflare pages deployment integration:
https://github.com/organizations/dwyl/settings/installations/34861696
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Share your constructive thoughts on how to make progress with this issue enhancement New feature or enhancement of existing functionality flutter Flutter related issues help wanted If you can help make progress with this issue, please comment! in-progress An issue or pull request that is being worked on by the assigned person priority-1 Highest priority issue. This is costing us money every minute that passes. research Research required; be specific T2h Time Estimate 2 Hours tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants