fgm / filog

A fine logger package for Meteor.JS applications (client + server)
GNU General Public License v3.0
18 stars 6 forks source link

BrowserProcessor's 'performance' entry is always {} #55

Closed yched closed 6 years ago

yched commented 6 years ago

window.performance.memory is an object of class MemoryInfo, which doesn't serialize to JSON : JSON.stringify(window.performance.memory) is "{}"

We need to explicitly include the three properties.

fgm commented 6 years ago

I had noticed that indeed.

yched commented 6 years ago

Any idea why it doesn't serialize properly by default ?

Not really, but the Chrome team seems to have intentianally designed window.performance.memory like a special snowflake (quantized values that only change every 20 minutes and hide small changes...)

And isn't there some more compact way to write this fix ?

No simple one, for the reasons above (super specific class)

The only generic way I found to access "all the properties in window.performance.memory" was Object.keys(Object.getPrototypeOf(window.performance.memory)), and then you still have to check whether they're a value or a function...

I do think the intended use is to access each known property individally and explicitly. If a new property gets added later on, it will just have to be explicitly extracted here.

Isn't there some per-browser variation on these subkeys ?

Nope, window.performance.memory is Chrome-only at the moment. If later on some other browser happened to add window.performance.memory as well, but without, say, the jsHeapSizeLimit property, then window.performance.memory.jsHeapSizeLimit would just be undefined, no big deal.

Small code formatting issue on bitHound linter

Will fix it

yched commented 6 years ago

About "some more compact way" :

fgm commented 6 years ago

I think we want to put this under windows.performance.memory, not under window.performance, though ? Otherwise we're losing any other content present under that standard key https://developer.mozilla.org/en-US/docs/Web/API/Performance

Which also means we need to check if window.performance is present at all in the result: this might be missing in a virtual browser, e.g. during SSR.

fgm commented 6 years ago

Discussed offline: since this overwriting is an earlier feature/bug, and we don't want to copy the whole window.performance object at this point, the change will just rename its stored result from performance to performance.memory, to leave room for other processors to insert the other parts of window.performance as desired.

fgm commented 6 years ago

Merged.