Closed Bug 795887 Opened 12 years ago Closed 12 years ago

Flush disk cache when Metro Firefox gets suspended

Categories

(Firefox for Metro Graveyard :: General, defect)

x86
Windows 8.1
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 19

People

(Reporter: bbondy, Assigned: bbondy)

References

Details

(Whiteboard: [metro-mvp] [LOE:1])

Attachments

(3 files, 8 obsolete files)

9.05 KB, patch
bbondy
: review+
Details | Diff | Splinter Review
4.21 KB, patch
bbondy
: review+
Details | Diff | Splinter Review
4.42 KB, patch
bbondy
: review+
Details | Diff | Splinter Review
+++ This bug was initially created as a clone of Bug #745075 +++ Currently we have 25% disk cache corruption on Metro Firefox. Bug 105843 tells the story of how the Necko disk cache is "corrupted" when the app crashes. On Metro Firefox, we can be killed by the OS when the app is suspended. The app is suspended anytime it is not the currently in use Metro application. We should flush the disk cache on a suspend notifications. This 25% will be greatly improved by the work I'm doing with bug 105843, but this should be done independent of that task.
Product: Firefox for Android → Firefox
Product: Firefox → Firefox for Metro
Version: unspecified → Trunk
Whiteboard: metro-beta → [metro-mvp]
Whiteboard: [metro-mvp] → [metro-mvp] [LOE:1]
So now that we have more users, the real stat here is 52% of startups have to nuke the old cache and start over. We can monitor telemetry data after this fix lands as well to see if we need to keep bug 105843 on the MVP list.
Attachment #676887 - Flags: review?(jmathies)
Attachment #676887 - Flags: review?(jmathies) → review+
Comment on attachment 676888 [details] [diff] [review] Patch v1 - Remove Android netwerk cache code from widget since it's handled in netwerk/cache now Looks good to me, but Brad is a better reviewer in widget.
Attachment #676888 - Flags: review?(mark.finkle)
Attachment #676888 - Flags: review?(blassey.bugs)
Attachment #676888 - Flags: feedback+
Comment on attachment 676884 [details] [diff] [review] Patch v1 - Adding process suspend observers where sleep ones exist What is the difference between the existing sleep_notification and application-background? Are these documented anywhere?
sleep_notification and wake_notification are documented here: https://developer.mozilla.org/en-US/docs/Observer_Notifications application-background and application-foreground are sent when a process is suspended, but not the whole computer. If this patch is r+'ed I'll update the documentation in the link above to add the 2 foreground/background ones. They should be added anyway since they already exist in mobile.
If they aren't documented in-code, they might as well not exist: MDN is a useless waste of time. Right now I don't see any particular reason for those to be separate notifications: are there any actual differences in behavior between the two? If not, can we just have a single notification which covers both cases?
They are 2 different events and I see value in having them distinct. Their frequency differs greatly. Firefox doesn't currently, but an application may at some point want to do an operation differently depending on if the computer is going to sleep or not. Firefox on Metro's process suspend notification will be sent every time a user switches out of the Metro browser for more than a few seconds. This may happen 50 times a day for example. The sleep notification will only happen when the computer goes to sleep which may happen for example once a day.
(In reply to Brian R. Bondy [:bbondy] from comment #11) > They are 2 different events and I see value in having them distinct. Their > frequency differs greatly. > > Firefox doesn't currently, but an application may at some point want to do > an operation differently depending on if the computer is going to sleep or > not. > > Firefox on Metro's process suspend notification will be sent every time a > user switches out of the Metro browser for more than a few seconds. This > may happen 50 times a day for example. The sleep notification will only > happen when the computer goes to sleep which may happen for example once a > day. Actually if these patches land there would be 1 differentiating factor between the 2 notifications. When Metro and Android suspend a process, it may be killed at any time for memory reasons. But when a computer goes to sleep, there is not much risk of the computer not waking up. So the netwerk patch in this bug will flush the cache only in the process suspended case.
Attachment #676888 - Flags: review?(blassey.bugs) → review+
Blocks: metro-misc
bsmedberg, I provided the reasons why I think it's better to have 2 notifications, but if you'd like I can consolidate the notifications into one, and I won't fight on it. It's mostly important to me just to get this done.
I think it's ok to have two if the behavior is actually going to be different. I just want to insist that they are documented in an appropriate header file.
(In reply to Benjamin Smedberg [:bsmedberg] from comment #14) > I think it's ok to have two if the behavior is actually going to be > different. Yup I gave the reasoning about why and how the behavior is different above. > I just want to insist that they are documented in an appropriate > header file. Is adding an explanatory comment to the existing places where we fire this from within widget/android and widget/win32 (source files) good enough? Otherwise which header should I define these observers in? I did a search for a few existing observers that I know about but didn't find a header file that contains all of observer topics.
nsXPCOM.h is a pretty good example. There isn't nor should there be a single header with all the observer topics listed. If these topics are primarily "widget-level" topics then I would expect them to be documented in some header in widget/. And no, I don't think documenting them at the site they are fired is good, because if/when they are added to other platforms, there needs to be a single site which explains the behavior.
Attachment #677532 - Flags: review?(roc)
Comment on attachment 677532 [details] [diff] [review] Patch v1 - Define sleep/suspend observers in widget Review of attachment 677532 [details] [diff] [review]: ----------------------------------------------------------------- r+ with that ::: widget/nsIWidget.h @@ +161,5 @@ > > /** > + * Before the OS goes to sleep, this topic is notified. > + */ > +#define NS_WIDGET_SLEEP_OBSERVER_ID "sleep_notification" call these TOPIC instead of ID
Attachment #677532 - Flags: review?(roc) → review+
:%s/_ID/_TOPIC/g Carrying forward r+.
Attachment #677532 - Attachment is obsolete: true
Attachment #677607 - Flags: review+
Attachment #676884 - Flags: review?(benjamin) → review+
Comment on attachment 676886 [details] [diff] [review] Path v1 - Add process suspend / resume handlers to shutdown and resume cache r+ with following nits fixed: > // Main thread may have already called nsCacheService::Shutdown > - if (!nsCacheService::gService || !nsCacheService::gService->mObserver) > + if (!nsCacheService::gService || !nsCacheService::IsInitialized()) > return NS_ERROR_NOT_AVAILABLE; I would prefer to move the check of nsCacheService::gService into nsCacheService::IsInitialized(). > - if (gService->mObserver) > + if (nsCacheService::IsInitialized()) > gService->mEnableDiskDevice = gService->mObserver->DiskCacheEnabled(); This check is not necessary. nsCacheService::SetDiskCacheCapacity() is called only from observer and from nsSetSmartSizeEvent::Run() where the check already is.
Attachment #676886 - Flags: review?(michal.novotny) → review+
Implemented review nits. Carrying forward r+.
Attachment #676888 - Attachment is obsolete: true
Attachment #678746 - Flags: review+
Attachment #676886 - Attachment is obsolete: true
Attachment #676888 - Attachment is obsolete: false
This is causing some Android tests to fail. I don't have the setup or time currently to investigate more, but here is the tbl logs: https://tbpl.mozilla.org/?tree=Try&rev=00c52b62a5de I'm going to just leave the Android code as it was and rename the notification for metro to process_suspend_notification. If we want to consolidate the Android code later and if that is a good idea, we can do that in a follow up.
Same as before just renamed observer topic to suspend_process_notification. Carrying forward r+.
Attachment #676888 - Attachment is obsolete: true
Attachment #678746 - Attachment is obsolete: true
Attachment #680308 - Flags: review+
Same as before, just renamed observer topic. Carrying forward r+.
Attachment #677607 - Attachment is obsolete: true
Attachment #680309 - Flags: review+
Renamed observer topic. Carrying forward r+.
Attachment #676884 - Attachment is obsolete: true
Attachment #680310 - Flags: review+
Attachment #676887 - Attachment is obsolete: true
Attachment #676885 - Attachment is obsolete: true
Blocks: 801199
No longer blocks: 687219, metro-misc
OS: Windows 8 Metro → Windows 8.1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: