Bug 1390800

Summary: evolution editor sluggish / slow when email message is long
Product: [Fedora] Fedora Reporter: Feng Yu <rainwoodman>
Component: evolutionAssignee: Milan Crha <mcrha>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 24CC: lucilanga, mbarnes, mcrha, tpopela
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-08 19:05:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
anonymized test message none

Description Feng Yu 2016-11-02 00:34:33 UTC
Description of problem:

The mail editor becomes extremely sluggish and irresponsive when email message is long.

Version-Release number of selected component (if applicable):

evolution-3.20.5-1.fc24.x86_64

How reproducible:

Always.

Steps to Reproduce:
1. Reply an email from a long thread. (with a lot of embedded quotation regions)
2. Focus the editor (plain text mode). Try to type

Actual results:

 CPU hops to 100% and letters slowly shows up.

Expected results:

 Typing shall be a crispy experience.

Additional info:

I can forward a few such long emails (not posting here due to privacy concerns) If I trim the email short the editor becomes responsive.

It seems to be actually due to webkitgtk or whichever editor widget evolution  is using. But could also be related to the coloring of embedded quotes. Earlier versions of evolution was fine.

Comment 1 Milan Crha 2016-11-02 13:01:23 UTC
Thanks for a bug report. I'll left the final word to Tomas Popela (CC'ed), I only want to note that the 3.22.0 (in the upcoming Fedora 25) uses WebKit2, instead of WebKit1, which makes the difference in particular cases. Yours might be too. Feel free to forward me (attached) one of such messages, to my bugzilla email address, only name this bug report in the Subject, otherwise I would overlook the email in my spam folder, and I'll test it here. We can close this in favour of the 3.22.x if it'll be fine, or investigate it further.

Comment 2 Feng Yu 2016-11-02 20:34:39 UTC
I forwarded an email to your redhat with the bug id. Did you receive it?

Comment 3 Feng Yu 2016-11-02 20:35:37 UTC
Auto line wrapping may be the culprit.

Comment 4 Milan Crha 2016-11-02 22:40:59 UTC
Thanks for the message, I received it fine. I see a higher CPU usage on open of the reply, which makes sense, because the message is more than 123KB long (byte-size of the attachment). After that I can type a new text in the message body (above/in the middle of the quoted part) without any significant UI sluggish, but I see a higher CPU usage in the system monitor (though nothing I would notice without it). I guess it's due to WebKit2 in the 3.22.0+.

What do you mean with "auto line wrapping"? You wrote into the message you sent me:
> Also note is if I turn off line wrapping it seems to be helpful.

Do you mean with that to change the paragraph style from Normal to Preformatted (using the Plain Text mode)? I tried that by selecting everything in the message (Ctrl+A) and and it caused a delay with a high CPU usage while processing the body, with some runtime warning on the console from the WebkitWebProcess too, but once the processing had been done it behaved reasonably well.

I noticed one thing when scrolling, for which I filled the below bug report upstream [1]. I think I'll anonymize the message and will attach it here (minimal headers with no private information, body text unreadable) and I'll upstream this bug report with it, for better visibility and such.

[1] https://bugzilla.gnome.org/show_bug.cgi?id=773864

Comment 5 Milan Crha 2016-11-02 22:42:54 UTC
A little update, I see sluggish when scrolling with mouse wheel, pretty significant. It's partly related to the above [1].

Comment 6 Milan Crha 2016-11-03 08:33:44 UTC
Created attachment 1216889 [details]
anonymized test message

This is anonymized version of the test message you sent me.

Tomas, do you want this to be filled upstream?

Comment 7 Feng Yu 2016-11-03 22:22:20 UTC
Thanks for looking into this.. I didn't realize we spend 130KB on the thread .. (in the end the model didn't work out as expected).

'line wrapping of quoted text' is a feature in the preferences.

It seems like if I turn it off the editing is smoother; but could be a placebo effect.

The worst is when I insert a new line within a block of quoted text. On my relatively beefy desktop computer it has a delay of around 500ms (measured by body clock)

Whenever I start replying long emails on my laptop (intel i5) the fans starts humming and everything becomes irresponsive. Evolution frequently hops to 100% CPU usage whatever I type.

Actually I have to note that the text box in Firefox also feels slightly sluggish comparing to vim. Not sure if it is possible something even deeper (pango?) that's also contributing to the problem.

Comment 8 Tomas Popela 2016-11-04 10:04:25 UTC
(In reply to Feng Yu from comment #7)
> The worst is when I insert a new line within a block of quoted text. On my
> relatively beefy desktop computer it has a delay of around 500ms (measured
> by body clock)

When I press return in the middle of text inside the block with the highest quote level in your message:

Elapsed Time for e_editor_dom_insert_new_line_into_citation: 604.438000 ms

and more specifically 567.391000 ms from these 604 is spent in WebKit by doing document.execCommand("InsertNewlineInQuotedContent", false).

Overall I don't see anything slow while trying the test message. I will look whether there is a possibility of cutting some time off from the initial load, but otherwise it's not slow for me at all (if I consider the size of the message).

Comment 9 Tomas Popela 2016-11-04 11:58:17 UTC
(In reply to Tomas Popela from comment #8)
> Overall I don't see anything slow while trying the test message. I will look
> whether there is a possibility of cutting some time off from the initial
> load, but otherwise it's not slow for me at all (if I consider the size of
> the message).

I managed to remove over 4 second from the loading time with [0]. It will be included in Evolution 3.22.2 (that will be part of F25).

[0] - https://git.gnome.org/browse/evolution/commit/?id=018fc0a247f8d9df0b88ddac5c088fec15252f6f

Comment 10 Feng Yu 2016-11-04 16:38:27 UTC
Mind the spell checker!

Thanks! I am looking forward upgrading to F25.

Given that almost no text has changed, spending 500ms on a new line seems to suggest an O(1) operation has blown to O(n) or even worse...

A possible way to understand this is to take a look at the data structure behind the editor?

gedit has highlighting, yet don't suffer from this (my impression may be wrong)..

Comment 11 Tomas Popela 2016-11-07 07:15:15 UTC
(In reply to Feng Yu from comment #10)
> Given that almost no text has changed, spending 500ms on a new line seems to
> suggest an O(1) operation has blown to O(n) or even worse...

Quite a few things is changing there. It maybe looks like a plain text, but in reality it's HTML. So what is happening is that you are splitting quite a few nested BLOCKQUOTEs and other elements up to the BODY element, re-layouting, rendering and doing other stuff, so it's definitely not a O(1) operation ;)..

> gedit has highlighting, yet don't suffer from this (my impression may be
> wrong)..

It's just operating with the plain text - things are easier there..

Comment 12 Feng Yu 2016-11-07 18:00:20 UTC
I see. It's likely because webkit was original designed for HTML document rendering and not HTML document editing.

In principle it should be possible to just relayout the changed, visible section; but it will be quite hard to do right -- just some thoughts for the future..

Thanks.

Comment 13 Fedora End Of Life 2017-07-25 23:43:21 UTC
This message is a reminder that Fedora 24 is nearing its end of life.
Approximately 2 (two) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 24. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '24'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 24 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 14 Fedora End Of Life 2017-08-08 19:05:42 UTC
Fedora 24 changed to end-of-life (EOL) status on 2017-08-08. Fedora 24 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.