Closed Bug 1211777 Opened 9 years ago Closed 1 year ago

[APZ] Text entry is much slower

Categories

(Core :: Panning and Zooming, defect, P3)

Unspecified
macOS
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: jryans, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: perf, Whiteboard: [gfx-noted])

Attachments

(1 file)

I've noticed in the last few weeks on Nightly, text entry has become a lot slower with APZ on, so much so that I had to turn off APZ to regain my sanity.

I see this issue pretty much anywhere you enter text, such as:

* Bugzilla comment field
* IRCCloud message field
* Telegram message field

When I type text with APZ on, there is a large delay (several seconds) before the characters are actually drawn to the screen.  They appear in spurts, many appearing, then none for a while, then another chunk.  

There seems to especially be a delay focused around hitting the full width of the text field, which has to grow vertically to fit the next line.  This process is the longest (several seconds again).

It seems like some kind of recent regression, as I don't remember it being like this a few weeks ago.
Can you get a profile on today's nightly (so that the profiler works again)?
Flags: needinfo?(jryans)
(In reply to Markus Stange [:mstange] from comment #1)
> Can you get a profile on today's nightly (so that the profiler works again)?

Do you prefer DevTools performance profiler, Gecko profiler add-on, or something else?
Flags: needinfo?(jryans) → needinfo?(mstange)
Gecko profiler add-on.
Flags: needinfo?(mstange)
I'll capture one when I see it again.  For the moment, today's Nightly (2015-10-06) seems somewhat better, so the issue is less obvious.
Are you still seeing this, or can we close this as WFM?
Flags: needinfo?(jryans)
I was finally able to get a good repro story.  I used today's build 2015-10-26.

It's easiest to repro on IRCCloud for me:

1. Go to some room in IRCCloud
2. Ensure there is enough history shown in the room so that it's possible to scroll the chat log vertically
3. Scroll the chat log up (back in time) and then all the way down (to the newest message)
4. Enter a new message in the text field that is longer than one line
5. Once the line hits the end of the text field and needs to wrap, there is a pause of several seconds
6. The problem no longer reproduces until the vertical scrolling of the chat log (step 3) is repeated

Here's the profile I captured:

http://people.mozilla.org/~bgirard/cleopatra/#report=f137860e0b62a3fdfd460487ac8949215009abf5
Flags: needinfo?(jryans)
Attached video Video of issue on IRCCloud (deleted) —
Here's a screen capture of the issue, including the scrolling needed to trigger it and the actual delay when wrapping the text field.
That profile seems to indicate that an irccloud JS script is taking up most of the time. Have you reproduced this behaviour on any site other than irccloud?
In particular the profile shows a large chunk of time spent inside a JS function called autoGrowInput which presumably is what runs when the input box expands from one line to two, as seen in your video. The profile seems to indicate it's doing a bunch of reflows triggered by calls to elementFromPoint. These are probably more expensive with APZ, but I suspect the same issue happens with APZ disabled as well, it's just not as obvious because the layout process is faster.

In comment 0 you say this happens in other text entry fields as well but if you can now only repro on IRCCloud then I think it's a less important issue. Still something we should look into but not something that would block APZ from riding the trains.
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #8)
> That profile seems to indicate that an irccloud JS script is taking up most
> of the time. Have you reproduced this behaviour on any site other than
> irccloud?

I used to be able to reproduce on other sites like Telegram and Bugzilla, but for the moment, I can only seem to trigger it on IRCCloud.
Ok, thanks! Let me know if you see it anywhere else.
Blocks: apz-desktop
No longer blocks: all-aboard-apz
Today I had the issue occur again on Telegram and Bugzilla, so outside of IRCCloud.

Here's my profile:

http://people.mozilla.org/~bgirard/cleopatra/#report=1dccd948ae57eaa21ad25c73be59484d11bc7ea5

I don't really have specific steps to cause these issues, they seems less predictable.  But I am definitely seeing multi-second hangs every ~10s even right now as I type this comment.
So the profile shows a multi-second GC on the content thread which is probably what is causing the issue here. On Telegram/Bugzilla, are you seeing the hangs when your text wraps to the next line, or even in the middle of the line? If the latter then it's likely a different root cause than the issue on IRCCloud.

It might be that we're leaking objects or something and giving the GC a hard time although I don't really know how to start debugging something like this.
I talked with Terrence on IRC about this, and he suggested:

13:15:20 terrence: kats: if you are able to run from a terminal and add environment variables easily, then set MOZ_GCTIMER=stdout
[snip]
13:20:25 terrence: kats: in that case, probably better to just have jryans run for a few days MOZ_GCTIMER spitting out data to the console and copy-paste the GC with the large Max Pause as soon as it happens
13:21:04 terrence: kats: if jryans still has that session open, then setting javascript.option.mem.log and copying any bad GC's that show up in the browser console would also be very helpful
13:21:25 terrence: kats: although those frequently get truncated, so it can be a bit hit or miss

jryans, can you try running with MOZ_GCTIMER=stdout and grab the GC log the next time you run into this? Thanks!
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #13)
> So the profile shows a multi-second GC on the content thread which is
> probably what is causing the issue here. On Telegram/Bugzilla, are you
> seeing the hangs when your text wraps to the next line, or even in the
> middle of the line? If the latter then it's likely a different root cause
> than the issue on IRCCloud.

Yes, these hangs with Telegram and Bugzilla were in the middle of lines, so I agree it's likely a separate issue than IRCCloud.

> It might be that we're leaking objects or something and giving the GC a hard
> time although I don't really know how to start debugging something like this.

I'll try the GC logging options you mentioned above.  Should I still report on this issue here, or file a new bug for it?
Let's split it into a new bug. We can leave this bug to track the IRCCloud issue. Thanks!
Blocks: paint-fast
Keywords: perf
Whiteboard: [gfx-noted]
Severity: normal → S3

Are you still experiencing this issue?

Flags: needinfo?(jryans)

(In reply to Gregory Pappas [:gregp] from comment #17)

Are you still experiencing this issue?

I do not recall experiencing this in recent years, but I've also stopped using IRCCloud where I used to notice it the most. Feel free to close if appropriate. 🙂

Flags: needinfo?(jryans)
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: