Git Product home page Git Product logo

Comments (6)

ignacioxd avatar ignacioxd commented on August 17, 2024

I can't seem to replicate this on my end. Could you provide more details about your environment's state? What OS/browser are you on? Is your service worker active?

from ragin-mages.

BrianFreemanAtlanta avatar BrianFreemanAtlanta commented on August 17, 2024

I am on windows 10 using normal/stable chrome (not canary). Yes there was a service worker going. It may be an issue with the service worker. Once I unchecked "enable offline" and also killed the service worker the error went away. If I enable offline and then refresh the error occurs again.

from ragin-mages.

adnanusman avatar adnanusman commented on August 17, 2024

I'm looking into this guys.

from ragin-mages.

adnanusman avatar adnanusman commented on August 17, 2024

Alright here are my thoughts on the service worker, please give me your inputs and then I will refactor it accordingly.

I am thinking we don't need two caches? When the service worker loads through the enable button it basically starts off by registering a service worker, which takes it to the SW file and then it initially loads up some static files. We can set it up so it just loads up all the assets immediately then, there's no need to send a second message to the service worker since its already doing a registration and already processing files into a cache. It could be the one single file. We can still have our cache dynamically populate any files we missed using the fetchAsset function only now we'll be fetching into the one cache.

Also I was thinking to add functionality where service worker deletes any caches if it is disabled by unchecking the enable service worker box. This could be done using messaging.

This is also related to #45

from ragin-mages.

ignacioxd avatar ignacioxd commented on August 17, 2024

I agree that a single cache is better. When the SW is loaded it should cache all files as you say. Here's what I think should happen:

  1. When the "enable service worker" box is checked, it should verify if the user is online. If the user is offline, caching cannot be enabled. This can be something we add later once we have the WebSocket portion abstracted out into a separate class.
  2. If the user is online, the SW will be installed.
    2.1. Option 1: Loading of assets does not start immediately, since the SW should not fetch another copy of the assets.json manifest. Instead, it will receive it in a message from the game. Remember that the game has this manifest already loaded in memory.
    2.2. Option 2: The SW loads the assets.json file once more and adds things to the cache without further intervention from the game. The problem with this approach is the additional request for the manifest and having to maintain the location of the manifest in two locations: the game and the SW.
  3. Once the SW has the manifest (via either option) it requests each asset/resource again to add it to the cache.

We should probably avoid dynamic caching (via fetch intercept) and instead ensure that our assets.json manifest is complete and correct. One location where we're currently dropping the ball is caching fonts and the web font loader script.

Deleting the cache when offline mode is disabled is a good idea.

from ragin-mages.

adnanusman avatar adnanusman commented on August 17, 2024

Thank you for the feedback.

from ragin-mages.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.