Closed
Bug 1216250
Opened 9 years ago
Closed 9 years ago
Limit amount of DOM Storage data stored by Session Restore
Categories
(Firefox :: Session Restore, defect)
Firefox
Session Restore
Tracking
()
RESOLVED
FIXED
Firefox 45
People
(Reporter: Yoric, Assigned: Yoric)
References
Details
(Keywords: dev-doc-complete)
Attachments
(2 files)
40 bytes,
text/x-review-board-request
|
ttaubert
:
review+
ritu
:
approval-mozilla-aurora+
|
Details |
14.74 KB,
patch
|
Details | Diff | Splinter Review |
No description provided.
Assignee | ||
Comment 1•9 years ago
|
||
Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r?ttaubert
Attachment #8676203 -
Flags: review?(ttaubert)
Updated•9 years ago
|
Attachment #8676203 -
Flags: review?(ttaubert)
Comment 2•9 years ago
|
||
Comment on attachment 8676203 [details]
MozReview Request: Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
https://reviewboard.mozilla.org/r/22627/#review20135
::: browser/components/sessionstore/content/content-sessionStore.js:24
(Diff revision 1)
> +XPCOMUtils.defineLazyModuleGetter(this, "DocShellCapabilities",
> + "resource:///modules/sessionstore/DocShellCapabilities.jsm");
Why are you moving this? The includes were alphabetically ordered before.
::: browser/components/sessionstore/content/content-sessionStore.js:723
(Diff revision 1)
> + let size = 0;
> + if (typeof collected == "object" && collected != null) {
> + for (let host of Object.keys(collected)) {
> + size += host.length;
> + let perHost = collected[host];
> + for (let key of Object.keys(perHost)) {
> + size += key.length;
> + let perKey = perHost[key];
> + size += perKey.length;
> + }
> + }
> + }
This doesn't seem like the right place for this code. I think we should move it into the SessionStorageListener and just ignore it there before pushing it onto the MessageQueue.
::: browser/components/sessionstore/content/content-sessionStore.js:738
(Diff revision 1)
> + if (size > Preferences.get("browser.sessionstore.dom_storage_limit", DOM_STORAGE_IS_TOO_LARGE)) {
> + // Discard. DOM storage will be recollected the next time and stored
> + // if it is now small enough.
> + continue;
> + }
I wouldn't default to introducing new preferences just because we think someone might want it. 1) Having less prefs is always preferable and 2) I don't think that anyone or any website really relies on us restoring DOMSessionStorage anyway.
Assignee | ||
Comment 3•9 years ago
|
||
https://reviewboard.mozilla.org/r/22627/#review20135
> Why are you moving this? The includes were alphabetically ordered before.
Well, they were semi-alphabetical, mixing resource:///modules/sessionstore and resource://gre/modules. I don't have to do that, of course, your call.
> This doesn't seem like the right place for this code. I think we should move it into the SessionStorageListener and just ignore it there before pushing it onto the MessageQueue.
If we do that, we lose the opportunity to send Telemetry to the parent process. There may be a way around it, but it seems more awkward. What do you think?
> I wouldn't default to introducing new preferences just because we think someone might want it. 1) Having less prefs is always preferable and 2) I don't think that anyone or any website really relies on us restoring DOMSessionStorage anyway.
Actually, the preference was for testing purposes.
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → dteller
Assignee | ||
Updated•9 years ago
|
Flags: needinfo?(ttaubert)
Comment 4•9 years ago
|
||
(In reply to David Rajchenbach-Teller [:Yoric] (use "needinfo") from comment #3)
> > Why are you moving this? The includes were alphabetically ordered before.
>
> Well, they were semi-alphabetical, mixing resource:///modules/sessionstore
> and resource://gre/modules. I don't have to do that, of course, your call.
I don't have a strong opinion here, was just wondering.
> > This doesn't seem like the right place for this code. I think we should move it into the SessionStorageListener and just ignore it there before pushing it onto the MessageQueue.
>
> If we do that, we lose the opportunity to send Telemetry to the parent
> process. There may be a way around it, but it seems more awkward. What do
> you think?
Hmmm, true. What about doing MessageQueue.push("telemetry", { ... }) and handling that separately in MessageQueue.send()? This way we could extend other Listeners/Collectors with telemetry in the future if needed.
Flags: needinfo?(ttaubert)
Assignee | ||
Updated•9 years ago
|
Attachment #8676203 -
Flags: review?(ttaubert)
Assignee | ||
Comment 5•9 years ago
|
||
Comment on attachment 8676203 [details]
MozReview Request: Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r?ttaubert
Updated•9 years ago
|
Attachment #8676203 -
Flags: review?(ttaubert)
Comment 6•9 years ago
|
||
Comment on attachment 8676203 [details]
MozReview Request: Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
https://reviewboard.mozilla.org/r/22627/#review21199
::: browser/components/sessionstore/content/content-sessionStore.js:50
(Diff revision 2)
> +const DOM_STORAGE_IS_TOO_LARGE = 10000000; // 10M characters
Maybe DOM_STORAGE_MAX_BYTES or _LIMIT_BYTES?
::: browser/components/sessionstore/content/content-sessionStore.js:568
(Diff revision 2)
> + // object, and block SessionStorage items that are too large. As a
> + // we also don't want to cause an OOM here, we use a quick and memory-
"As a we also..." probably just remove the "a"?
::: browser/components/sessionstore/content/content-sessionStore.js:572
(Diff revision 2)
> + let size = 0;
> + for (let host of Object.keys(collected)) {
> + size += host.length;
> + let perHost = collected[host];
> + for (let key of Object.keys(perHost)) {
> + size += key.length;
> + let perKey = perHost[key];
> + size += perKey.length;
> + }
> + }
I think this should move into a separate function, probably together with the comment.
Assignee | ||
Comment 7•9 years ago
|
||
Comment on attachment 8676203 [details]
MozReview Request: Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r?ttaubert
Attachment #8676203 -
Flags: review?(ttaubert)
Comment 8•9 years ago
|
||
Comment on attachment 8676203 [details]
MozReview Request: Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
https://reviewboard.mozilla.org/r/22627/#review21231
::: browser/components/sessionstore/content/content-sessionStore.js:564
(Diff revision 3)
> + if (!storage) {
> + return 0;
> + }
Looks like |storage| would always be true-ish.
::: browser/components/sessionstore/content/content-sessionStore.js:587
(Diff revision 3)
> + if (collected == null) {
> + return collected;
> + }
We can remove the check above due to this, OTOH do we want to omit reporting zeros? Do we want to know how many pages have no DOMSessionStorage data?
Attachment #8676203 -
Flags: review?(ttaubert) → review+
Assignee | ||
Comment 9•9 years ago
|
||
https://reviewboard.mozilla.org/r/22627/#review21231
> Looks like |storage| would always be true-ish.
Yes, I wanted to be on the safe side.
> We can remove the check above due to this, OTOH do we want to omit reporting zeros? Do we want to know how many pages have no DOMSessionStorage data?
I suspect that we don't care all that much about pages with no DOMSessionStorage data. This histogram is about how much memory it takes when there is some data, so no need to feed 99.9% of 0s to the server.
I have documented this in the histogram.
Assignee | ||
Updated•9 years ago
|
Attachment #8676203 -
Attachment description: MozReview Request: Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r?ttaubert → MozReview Request: Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
Assignee | ||
Comment 10•9 years ago
|
||
Comment on attachment 8676203 [details]
MozReview Request: Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
DOM Storage is a pretty inefficient and memory-hungry storage mechanism. Session Store attempts to record DOM Storage for each tab, which leads to (possibly very large) objects being serialized once to be sent from frame/content to parent and once to be sent from the main thread to the I/O thread. This is a suspect behind a number of crashes (see bug 1106264 for a discussion on the topic).
This patch limits the amount of DOM Storage that Session Restore attempts to store. We perform a quick estimate on the amount of memory needed to serialize DOM Storage and prevent storage larger than ~10M chars being sent from frame/content to the parent. Once this patch has landed, we will need to watch FX_SESSION_RESTORE_DOM_STORAGE_SIZE_ESTIMATE_CHARS to find out whether our threshold is meaningful.
Assignee | ||
Comment 11•9 years ago
|
||
Assignee | ||
Comment 12•9 years ago
|
||
Assignee | ||
Comment 13•9 years ago
|
||
Comment on attachment 8676203 [details]
MozReview Request: Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
DOM Storage is a pretty inefficient and memory-hungry storage mechanism. Session Store attempts to record DOM Storage for each tab, which leads to (possibly very large) objects being serialized once to be sent from frame/content to parent and once to be sent from the main thread to the I/O thread. This is a suspect behind a number of crashes (see bug 1106264 for a discussion on the topic).
This patch limits the amount of DOM Storage that Session Restore attempts to store. We perform a quick estimate on the amount of memory needed to serialize DOM Storage and prevent storage larger than ~10M chars being sent from frame/content to the parent. Once this patch has landed, we will need to watch FX_SESSION_RESTORE_DOM_STORAGE_SIZE_ESTIMATE_CHARS to find out whether our threshold is meaningful.
Assignee | ||
Comment 14•9 years ago
|
||
Keywords: checkin-needed
Comment 15•9 years ago
|
||
Hi, this failed to apply:
applying 7756fb39915c
patching file browser/components/sessionstore/content/content-sessionStore.js
Hunk #4 FAILED at 718
1 out of 4 hunks FAILED -- saving rejects to file browser/components/sessionstore/content/content-sessionStore.js.rej
patching file toolkit/components/telemetry/Histograms.json
Hunk #1 FAILED at 4346
1 out of 1 hunks FAILED -- saving rejects to file toolkit/components/telemetry/Histograms.json.rej
Flags: needinfo?(dteller)
Keywords: checkin-needed
Assignee | ||
Comment 16•9 years ago
|
||
Most likely bitrotten by bug 1214408. I'll unbitrot once that one has finished landing.
Flags: needinfo?(dteller)
Assignee | ||
Comment 17•9 years ago
|
||
Comment on attachment 8676203 [details]
MozReview Request: Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
DOM Storage is a pretty inefficient and memory-hungry storage mechanism. Session Store attempts to record DOM Storage for each tab, which leads to (possibly very large) objects being serialized once to be sent from frame/content to parent and once to be sent from the main thread to the I/O thread. This is a suspect behind a number of crashes (see bug 1106264 for a discussion on the topic).
This patch limits the amount of DOM Storage that Session Restore attempts to store. We perform a quick estimate on the amount of memory needed to serialize DOM Storage and prevent storage larger than ~10M chars being sent from frame/content to the parent. Once this patch has landed, we will need to watch FX_SESSION_RESTORE_DOM_STORAGE_SIZE_ESTIMATE_CHARS to find out whether our threshold is meaningful.
Comment 20•9 years ago
|
||
Keywords: checkin-needed
Comment 21•9 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox45:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 45
Comment 22•9 years ago
|
||
Hi Yoric, if this looks good on m-c and will help with bug 1106264, want to request uplift?
Flags: needinfo?(dteller)
Assignee | ||
Comment 23•9 years ago
|
||
I'd like to wait a few days and check if this breaks anything.
Flags: needinfo?(dteller)
Comment 24•9 years ago
|
||
Added the site compatibility doc: https://www.fxsitecompat.com/en-US/docs/2015/session-storage-data-size-is-now-limited-to-10-mb/
Keywords: dev-doc-needed,
site-compat
Comment 25•9 years ago
|
||
Hi Yoric, what do you think? Here's the latest session restore bugs from when this patch landed until today:
https://bugzilla.mozilla.org/buglist.cgi?list_id=12689962&chfieldto=2015-11-18&query_format=advanced&chfield=[Bug%20creation]&chfieldfrom=2015-11-05&component=Session%20Restore&product=Firefox
Flags: needinfo?(dteller)
Assignee | ||
Comment 26•9 years ago
|
||
Hi Liz, I'm afraid I don't understand the question.
Flags: needinfo?(dteller) → needinfo?(lhenry)
Assignee | ||
Comment 27•9 years ago
|
||
(In reply to Kohei Yoshino [:kohei] from comment #24)
> Added the site compatibility doc:
> https://www.fxsitecompat.com/en-US/docs/2015/session-storage-data-size-is-
> now-limited-to-10-mb/
Actually, that's not exactly the case. It's the amount of data that is recorded in case of crash/restart. The amount of data that can be stored by a webpage hasn't changed.
Flags: needinfo?(kohei.yoshino)
Comment 28•9 years ago
|
||
Ah okay, will delete the compat doc then. Thanks!
Flags: needinfo?(kohei.yoshino)
Comment 29•9 years ago
|
||
Do you want to uplift this to aurora or beta, was the original question.... then you mentioned waiting a few days to see if this breaks anything.
I checked the list of newly reported session restore bugs to see if there were any obvious regressions. While there are some new bugs, I'm not sure how to tell if they're related.
It's getting late to uplift this to beta, but you could still request uplift to 44 if that seems like a good idea to you.
Flags: needinfo?(lhenry)
Comment 30•9 years ago
|
||
Deleted the doc, clearing the keywords.
Keywords: dev-doc-needed,
site-compat
Assignee | ||
Comment 31•9 years ago
|
||
@lizzard Ah, good point.
Assignee | ||
Comment 32•9 years ago
|
||
Comment on attachment 8676203 [details]
MozReview Request: Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
Approval Request Comment
[Feature/regressing bug #]: Making Session Restore compatible with e10s, a long time ago.
[User impact if declined]: OOM Crashes.
[Describe test coverage new/current, TreeHerder]: This has now been on m-c for a few weeks.
[Risks and why]: In case of crash or restart, some webpages that consume too much memory may not be restored properly. We don't know of any such page yet.
[String/UUID change made/needed]:
Attachment #8676203 -
Flags: approval-mozilla-aurora?
Comment on attachment 8676203 [details]
MozReview Request: Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore;r=ttaubert
This fixes possible OOM crashes and definitely the kind of fix (once stable) seem worthy of uplifting to Aurora44. It was on Nightly for almost 3 weeks, approved.
Attachment #8676203 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
tracking-firefox44:
--- → +
Comment 34•9 years ago
|
||
this cause problems uplifting to aurora:
grafting 313277:abbcb9ec539b "Bug 1221356 - Don't package mozharness for Thunderbird builds. r=gps"
Tomcats-MacBook-Pro-2:mozilla-central Tomcat$ hg graft --edit -r bb09cf018056
grafting 313196:bb09cf018056 "Bug 1216250 - Limit amount of DOM Storage data stored by Session Restore. r=ttaubert"
merging browser/components/sessionstore/content/content-sessionStore.js
merging toolkit/components/telemetry/Histograms.json
warning: conflicts during merge.
merging toolkit/components/telemetry/Histograms.json incomplete! (edit conflicts, then use 'hg resolve --mark')
abort: unresolved conflicts, can't continue
(use hg resolve and hg graft --continue)
could you take a look, thanks!
Flags: needinfo?(dteller)
Assignee | ||
Comment 35•9 years ago
|
||
Flags: needinfo?(dteller)
Comment 37•9 years ago
|
||
bugherder uplift |
Comment 38•9 years ago
|
||
bugherder uplift |
status-b2g-v2.5:
--- → fixed
Comment 39•9 years ago
|
||
(In reply to David Rajchenbach-Teller [:Yoric] (use "needinfo") from comment #36)
> Does this work better?
yeah thanks!
status-b2g-v2.5:
fixed → ---
Flags: needinfo?(cbook)
Comment 40•9 years ago
|
||
I thought this should perhaps be recorded somewhere in the docs, just in case — have a look at the top note in the first section of this doc:
https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API
Does this wording read ok?
Assignee | ||
Comment 41•9 years ago
|
||
Thanks. I have changed one word.
Updated•9 years ago
|
Keywords: dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•