Adding markers to a Google map is visibly slower than in IE, Chrome, etc.
Categories
(Core :: Performance: Responsiveness, defect, P3)
Tracking
()
| Performance Impact | medium |
People
(Reporter: JeremyHussell, Assigned: jesup)
Details
(Keywords: perf, perf:responsiveness)
Attachments
(4 files, 2 obsolete files)
Updated•7 years ago
|
Updated•7 years ago
|
| Assignee | ||
Comment 1•7 years ago
|
||
| Assignee | ||
Comment 2•7 years ago
|
||
| Assignee | ||
Comment 3•7 years ago
|
||
| Assignee | ||
Updated•7 years ago
|
| Assignee | ||
Comment 4•7 years ago
|
||
| Assignee | ||
Comment 5•7 years ago
|
||
| Assignee | ||
Comment 6•7 years ago
|
||
Comment 7•7 years ago
|
||
| Assignee | ||
Comment 8•7 years ago
|
||
| Reporter | ||
Comment 9•7 years ago
|
||
Comment 10•7 years ago
|
||
Updated•7 years ago
|
Updated•6 years ago
|
| Assignee | ||
Comment 11•6 years ago
|
||
Daniel, thoughts on who should look at this?
Comment 12•6 years ago
•
|
||
I don't know without investigating, so I just went ahead and investigated.
Focusing on the original testcase: it looks like the difference between us and Chrome there is as follows: Firefox yields for a refresh-driver-tick (and repaint) between consecutive setTimeout callbacks, whereas Chrome does not. I'll attach a testcase that demonstrates this.
This behavior-difference just so happens to benefit Chrome in this scenario, where they have manymany setTimeout calls queued up, each of which triggers a non-trivial chunk of styling/layout/painting if it's given an opportunity right away. Chrome doesn't yield & hence gets to coalesce the effects of all of those setTimeout callbacks, while we yield for a refresh driver tick between the setTimeout callbacks. In general (not on this specific testcase), this means we tend to seem more responsive (repainting & handling user input more frequently), but Chrome will reach its final rendering a bit faster (due to skipping over intermediate renderings).
Comment 13•6 years ago
|
||
Here's a very simple testcase which I think is effectively the same as this bug (though in this case the repaints are cheaper).
Firefox yields for a repaint between each queued-up setTimeout callback here, so we show each value of the incrementing counter. But Chrome does not -- they don't paint any intermediate states, just the final value.
Comment 14•6 years ago
|
||
smaug, do you know if we've got other bugs open about this behavior-difference between Firefox and Chrome? (firefox yielding for refresh driver ticks between previously-queued-up setTimeout invocations, vs. Chrome not yielding)
Does this belong in DOM perhaps?
Comment 15•6 years ago
|
||
oh, interesting. Chrome janks badly.
Comment 16•6 years ago
|
||
We do have pref dom.timeout.max_consecutive_callbacks_ms, and increasing that a lot changes the behavior on the testcase. (I tested 10000, which is silly).
Does increasing dom.timeout.max_consecutive_callbacks_ms significantly affect Google Maps?
Comment 17•6 years ago
•
|
||
Thanks - yes, if I make that pref adjustment, then the original Google Maps testcase here loads as-expected (the same way it loads in Chrome). There are only a couple flashes of painted content, rather than many many "per-marker" repaints, and we reach the final rendering sooner.
Here's a profile with that pref-tweak: https://perfht.ml/2YyVLxU
vs. a profile with default pref value: https://perfht.ml/2YvZ7Sn
Comment 18•6 years ago
|
||
I noticed this too browsing google maps. Occasionally when I zoom in and out to see different portions of the map, the zoom out view will be stuck with blank content on parts of the screen for a long time (13 seconds)
https://perfht.ml/2WQDLia
Changing the pref to 1000, I can get a split second of blank content but it usually resolves quickly.
| Assignee | ||
Comment 19•6 years ago
|
||
So other than saying "Don't do that!", are there any options here?
One option would be to treat 0ms SetTimeouts differently than others.... don't apply the same max_consecutive_callbacks for string of 0ms timeouts waiting to fire (use a higher-but-not-infinite limit perhaps). 0ms timeouts aren't really "timeouts", they're "let other events in" or a form of continuation programming
| Assignee | ||
Comment 20•6 years ago
|
||
Hmmm. Vicky, looking at your profile (if it caught the freeze), I don't see a barrage of timeouts: https://perfht.ml/2HuGKGE
and https://perfht.ml/2HsjIjK
I suspect whatever is blocking you is not on MainThread... a worker? There are no DOM events really until it "comes alive" again (https://perfht.ml/2Hy4CZZ)
This zoom in on one of the few DOM events in the freeze is interesting... https://perfht.ml/2HC4ngK MozLocalStorageChanged
perhaps profile workers and Quota (LSNG maybe?)
Comment 21•6 years ago
|
||
Here's another profile with more threads captured:
https://perfht.ml/2WNCN6s
Comment 22•6 years ago
|
||
Yeah, setTimeout(, 0) could be perhaps treated differently. But still, painting should happen between those, even the spec seems to hint about that.
This does feel like Google maps is relying on jank-y behavior in Chrome.
| Assignee | ||
Comment 23•6 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #22)
Yeah, setTimeout(, 0) could be perhaps treated differently. But still, painting should happen between those, even the spec seems to hint about that.
You can make a real argument that setTimeout(0) is expected to do different things than "normal" timeouts.
This does feel like Google maps is relying on jank-y behavior in Chrome.
We can poke them if we have contacts on the Maps team
Mike?
| Assignee | ||
Comment 24•6 years ago
|
||
| Assignee | ||
Comment 25•6 years ago
|
||
Yeah, setTimeout(, 0) could be perhaps treated differently. But still, painting should happen between those, even the spec seems to hint about that.
You can make a real argument that setTimeout(0) is expected to do different things than "normal" timeouts.
I did an experimental patch that allows sequences of 0ms timers to run for longer (25ms instead of 4ms) before exiting the timeout loop. This only applies to 0ms timers, and only for so long as the entire set being run in RunTimeout are 0ms (though it doesn't check before running a timeout, only after - I could do that, and move the zero-ms/"over timeout" check before the running the each timeout instead of after.
Net result: ~4-4.5s vs 7.5s. Chrome on this machine is around 2-2.5s. Setting it to effectively infinite causes it to take 3.5s. Note that we still kick out and allow gfx to start painting if a non-0 one gets in there
smaug: thoughts?
| Assignee | ||
Comment 26•6 years ago
|
||
mike - after discussion and some experiments: if they (google) want that (janky) behavior when putting a ton of pins in (i.e. don't paint much if at all until done), they can use resolved promises (i.e. microtasks, which happen before paint). If they want to limit the duration of jank in that impl, they can limit the number/time-spent of promises before spinning the event loop via setTimeout(..., 0).
I suspect this may be an edge-case they don't care about much, as it's not main Google Maps app; it's using the API.
Comment 27•5 years ago
|
||
Sorry for dropping the ball on this one. Does this still reproduce as described? For me, the performance appears to be the same in Firefox and Chrome now (though, just visually, not measuring).
| Reporter | ||
Comment 28•5 years ago
|
||
Yes, it still reproduces as described on the latest versions of Firefox and Chrome. (https://bugzilla.mozilla.org/attachment.cgi?id=9025377) From previous discussion, it seems the Google Maps team is taking advantage of a bug in Chrome (accidentally?), and not actually a bug in Firefox, which I presume is why everyone stopped paying attention to this issue.
Updated•5 years ago
|
Comment 29•4 years ago
|
||
Is this still an issue?
(I tried the initial testcase and it caused Chrome (parent process!) to hang every now an then)
| Reporter | ||
Comment 30•4 years ago
|
||
Testing on the latest versions of Firefox and Chrome, the behaviour is now indistinguishable. Unfortunately - from my point of view - what changed is that the timer bug in Chrome has been fixed, so the example is now just as slow on Chrome as it is on Firefox. Now all that's left is a performance issue for the Google Maps API team to deal with.
Thank you, everyone who helped track down the cause of this issue. Even though I'm still annoyed by the enormous difference in performance between adding the same markers in different ways, I acknowledge that making Firefox bug-for-bug compatible with Chrome would have been the wrong thing to do. With the Chrome bug fixed, the Maps people will, hopefully, be pushed to change their code to add markers quickly no matter which browser is being used.
Comment 31•4 years ago
|
||
Thanks for confirming that! Sounds like this bug can be closed, then.
I'll close this as INVALID, in the sense that there-is-no-Firefox-bug-to-be-fixed-here. (To the extent that a bug exists, it's a perf bug on the Google Maps side, which [now] affects all browsers, as best we can tell.)
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Updated•8 months ago
|
Description
•