Closed Bug 1248447 Opened 8 years ago Closed 8 years ago

Stop grafting prototypes in storage.js::patchMetadataMapsAndProtos()

Categories

(DevTools :: Storage Inspector, defect, P3)

defect

Tracking

(firefox48 fixed)

RESOLVED FIXED
Firefox 48
Tracking Status
firefox48 --- fixed

People

(Reporter: miker, Unassigned)

Details

(Whiteboard: [btpp-backlog])

Attachments

(1 file)

When the object store moves from one process to another it has been through JSON.stringify() and JSON.parse() so it loses it's important methods and Maps are changed from Maps to arrays of arrays.

To work around this issue we graft the __proto__ object and change the arrays of arrays back to patches but this is bad practice and has a negative effect on JavaScript performance.

It seems like there must be a better way to do this... maybe there are properties here that we don't need and maybe we are better not to use Maps. We should check which values we *need* and see if we can provide them.

Here is the offending method:

patchMetadataMapsAndProtos: function(metadata) {
  for (let [, store] of metadata._objectStores) {
    store.__proto__ = ObjectStoreMetadata.prototype;

    if (typeof store._indexes.length !== "undefined") {
      store._indexes = new Map(store._indexes);
    }

    for (let [, value] of store._indexes) {
      value.__proto__ = IndexMetadata.prototype;
    }
  }

  metadata._objectStores = new Map(metadata._objectStores);
  metadata.__proto__ = DatabaseMetadata.prototype;
}
Doing bug triage with Emma.
Filter on LOBSTER-THERMADOR
Priority: -- → P3
Whiteboard: [btpp-backlog]
Attachment #8731727 - Flags: review?(pbrosset)
Comment on attachment 8731727 [details]
MozReview Request: Bug 1248447 - Stop grafting prototypes in storage.js::patchMetadataMapsAndProtos() r?pbrosset

https://reviewboard.mozilla.org/r/40795/#review37851

I was not familiar with this part of the code before, and I'm not too sure what some of DatabaseMetadata does, but this looks like a simple change that helps with performance and gets rid of `__proto__`, which is good.
Attachment #8731727 - Flags: review?(pbrosset) → review+
https://hg.mozilla.org/mozilla-central/rev/297bb754e231
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 48
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.