Closed Bug 1076366 Opened 10 years ago Closed 9 years ago

Work Offline mode prevents the application cache from working until the browser is restarted

Categories

(Core :: Networking: Cache, defect)

32 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: chris-dev, Assigned: mayhemer)

References

Details

Attachments

(2 files)

Attached file firefox.php
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0
Build ID: 20140923175406

Steps to reproduce:

User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:33.0) Gecko/20100101 Firefox/33.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:34.0) Gecko/20100101 Firefox/34.0

When Work Offline is enabled the application cache doesn't work correctly after Work Offline is disabled. This issue seems to occur under normal operation with an unreliable internet connection when Firefox brings up the "Offline mode - Firefox is currently in offline mode and can't browse the Web" page after visiting a site with an application cache.

Please refer to attached firefox.php (simple page with a manifest and displays application cache events).

Steps to reliably reproduce this issue:

- Ensure File -> Work Offline is unticked
- Visit http://localhost/firefox.php
  - "init, checking, downloading, progress, cached" is displayed
- Enabled Work Offline: File -> Work Offline (tick)
- Clear application cache: Tools -> Options -> Advanced -> Network -> The following web sites are allowed to store data for offline use -> localhost -> Remove, Remove offline data
- Reload the page (F5)
  - "init, checking, error" is displayed
- Reload the page (F5) - this is where the application cache stops working correctly
  - "init, checking" is displayed
- Reload the page (F5)
  - "init" is displayed
- Disable Work Offline: File -> Work Offline (untick)
- Reload the page (F5)
  - "init" is displayed
- Restart Firefox
- Visit http://localhost/firefox.php - application cache works correctly again
  - "init, checking, downloading, progress, cached" is displayed
- Reload the page (F5)
  - "init, checking, noupdate" is displayed

While these steps aren't something a user would normally do, Firefox can get into the same unusable state when using an unreliable internet connection. Firefox >= 32 is affected and Firefox 31 is not.


Actual results:

When Work Offline is enabled the application cache stops firing error events and eventually fires no events at all. After Work Offline is disabled the application cache does not fire events until the browser is restarted.


Expected results:

When Work Offline is enabled the application cache should continue to fire error events. After Work Offline is disabled the application cache should update and fire events normally.

Firefox 31 is unaffected:

User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0

- Ensure File -> Work Offline is unticked
- Visit http://localhost/firefox.php
  - "init, checking, downloading, progress, cached" is displayed
- Enabled Work Offline: File -> Work Offline (tick)
- Clear application cache: Tools -> Options -> Advanced -> Network -> The following web sites are allowed to store data for offline use -> localhost -> Remove, Remove offline data
- Reload the page (F5)
  - "init, checking, error" is displayed
- Reload the page (F5)
  - "init, checking, error" is displayed
- Reload the page (F5) - correctly firing the error event
  - "init, checking, error" is displayed
- Disable Work Offline: File -> Work Offline (untick)
- Reload the page (F5) - correctly updating the application cache
  - "checking, downloading, progress, cached" is displayed
- Reload the page (F5)
  - "init, checking, noupdate" is displayed
Thanks for the detailed test case.  Probably a new cache v2 regression.  I'll take a look but don't expect this be fixed ASAP, we don't invest much time to appcache anymore.
Assignee: nobody → honzab.moz
Setting the preference browser.cache.use_new_backend_temp to false stops this issue from occurring.
We have this same issue and the preference noted above resolves the issue. Would you be able to comment on the planned lifetime of the preference setting? Ideally it will remain an option for a long time to give our userbase a workaround for this bug.

If the preference is removed while this bug still exists, then Firefox will effectively be broken for our users.
Flags: needinfo?(honzab.moz)
(In reply to Robert from comment #3)
> We have this same issue and the preference noted above resolves the issue.
> Would you be able to comment on the planned lifetime of the preference
> setting? Ideally it will remain an option for a long time to give our
> userbase a workaround for this bug.
> 
> If the preference is removed while this bug still exists, then Firefox will
> effectively be broken for our users.

I'll definitely fix this before we remove the preference.  I'll try to take a look on how complicated this could be to fix.  Tho, since work-offline is purely a user's choice these days (auto-detection is off AFAIK - feel free to fix me :)) then I don't see this as highly impacting.
Flags: needinfo?(honzab.moz)
Thanks Honza! That sounds perfect.
Blocks: 913828
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attached patch v1Splinter Review
Thanks again for the perfect STR and test case!

Cause:
- the channel reading the manifest in step 5 of the STR opens its normal cache entry as read only (offline state) while later finds out it should be revalidated (based on expiration time only in this case)
- returns ENTRY_NEEDS_REVALIDATION
- CacheEntry switches to REVALIDATING state
- at CacheEntry::InvokeAvailableCallback state != READY and callback opens r/o
=> ENTRY_NOT_FOUND is returned to the channel + (the important) the state of the entry remains REVALIDATING and has no way to go back
=> subsequent open of the same entry (left in memory) is blocked forever

Solution:
- annotate callbacks whom OnCacheEntryCheck returned ENTRY_NEEDS_REVALIDATION with a "revalidating" flag set
- such callbacks despite being r/o are allowed to get the entry as "writers" and proceed with the validation

https://treeherder.mozilla.org/#/jobs?repo=try&revision=8a6c1361366f
Attachment #8567280 - Flags: review?(michal.novotny)
Attachment #8567280 - Flags: review?(michal.novotny) → review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/c3832f445568
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in before you can comment on or make changes to this bug.