Closed Bug 1216181 Opened 10 years ago Closed 10 years ago

Standalone sometimes doesn't load in development environment (init undefined)

Categories

(Hello (Loop) :: Client, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Mardak, Unassigned)

References

Details

(Whiteboard: [tech-debt][fixed by bug 1215322])

When making a screenshot for bug 1215487, I noticed sometimes the standalone just appeared blank/white: Uncaught TypeError: Cannot read property 'init' of undefined (anonymous function) @ E5YX9BeZrw0:186 fireLocalizedEvent @ l10n-gaia-02ca67948fe8.js:1717 onReady @ l10n-gaia-02ca67948fe8.js:1706 ee_emit @ l10n-gaia-02ca67948fe8.js:94 setReady @ l10n-gaia-02ca67948fe8.js:1277 onL10nLoaded @ l10n-gaia-02ca67948fe8.js:1093 onPropLoaded @ l10n-gaia-02ca67948fe8.js:1118 io_load @ l10n-gaia-02ca67948fe8.js:34 dmose, could this be related to the combining js files?
Possibly. Mark and I were talking last week, and he mentioned he thought he knew of a way that the l10n stuff could race which might be causing functional test intermittents. And I'm wondering if this is somehow related to that. Giving him a needinfo, as I didn't get the details... Interestingly, using Chrome Canary, I've reproduced this once against localhost (use the non-bundled version) and not yet at all against the production instance (which uses the bundled version). That said, the change that turned on bundling changed both code paths, so this problem might still be related to that.
Flags: needinfo?(standard8)
Looking at the code: <script> // Wait for all the localization notes to load window.addEventListener("localized", function() { loop.webapp.init(); }, false); </script> This seems like a race where localized fires before loop.webapp.init has been assigned to. I'm not sure why that would happen, but I'll poke around a bit.
Flags: needinfo?(standard8)
Flags: needinfo?(standard8)
OK, so after talking to Ed, we're only aware of this having been seen on localhost so far. That said, there clearly is a race in the code, where if the localized event gets fired before loop.webapp has been assigned to, things blow it. It's easier to imagine that happening in the development mode given the way require() is currently shimmed, but I haven't yet convinced myself that it couldn't happen in production. It'll be nice to get sentry up and running, as that would, I think, let us know if this ever happens in production (assuming all exceptions get uploaded, not just a sampling).
Until we have some reason to believe that this is happening in production, I'm going to drop the rank on this down to the bottom twenties.
Rank: 29
Priority: -- → P2
Whiteboard: [tech debt]
I've also seen this in Firefox occasionally. I'm pretty sure this is only development where this is happening. On production, we have a single script load for standalone.js that is then processed as a whole before l10n-gaia-...js has time to fire off the load for the l10n file (and then the localized event). However on development we now have a two step process: load webappEntryPoint.js, insert script tags for the rest. So I think what happens is that the scripts start to load as async, so the l10n-gaia-...js file gets loaded way before the rest of the scripts it loads its file, then at that stage fires the localized event, which is sometimes before the rest of the scripts have loaded. I think if this wasn't a development only issue, then we'd be have been hitting it in production ages ago, as we haven't really changed that flow (apart from combining the scripts). I might be able to address this in bug 1212428. I think this is also causing the occasional intermittent failure on the functional tests.
Depends on: 1212428
Flags: needinfo?(standard8)
Summary: Chrome often doesn't load standalone (init undefined) → Standalone sometimes doesn't load in development environment (init undefined)
This was fixed by the changed that were done in bug 1215322.
Status: NEW → RESOLVED
Closed: 10 years ago
Depends on: 1215322
Resolution: --- → FIXED
Whiteboard: [tech debt] → [tech-debt][fixed by bug 1215322]
You need to log in before you can comment on or make changes to this bug.