Author Topic: Extremely slow message load for some emails with external links/images  (Read 224 times)

Offline linuxgod

  • Newbie
  • *
  • Posts: 4
Running Roundcube version 1.4.9 which I built from source, though I have had this issue for a while with the stock Ubuntu version 1.4.3 (and older versions too, though I can't say precisely when this started)


I've not yet been able to isolate precisely why this is happening or where in the code, but some emails consistently have this issue.  Click to load the message and it takes 5-6 seconds to completely load.  Some emails load fine consistently.  Some take 5-6 seconds to load consistently.  The same senders tend to have issues, but not always.  This is not an IMAP or SMTP or DNS issue from what I can tell - it has something to do with generating the stylesheet in the task=utils or action=modcss call, I believe. Almost all of this time (~5.2 out of 5.4 seconds)is spent in the following call:

?_task=utils&_action=modcss&_u=tmp-5f419b7f3c624a8a0ddc3a6212c91d5f.css&_c=message-htmlpart1

Note that if I go to the above link directly on my webmail server all it's doing is generating the attached stylesheet.  So why does this take 5+ seconds?!?!

Attaching the network timing info/waterfall from Chrome.  Also attaching a sample email that causes issues.  Note headers have been scrubbed of personal username/hostname with $USER/$MAILHOST but message is otherwise intact.

Side note: I went and disabled all plugins thinking perhaps one of them was triggering this issue but it made no difference in performance.

Offline linuxgod

  • Newbie
  • *
  • Posts: 4
Re: Extremely slow message load for some emails with external links/images
« Reply #1 on: December 03, 2020, 10:51:39 AM »
source of the slowness is in the following call, line 44 of steps/utils/modcss.inc

    $source  = @file_get_contents($realurl, false, $context);

If I put an exit just before that line the message immediately loads.  If I put an exit after the line it takes ~5 seconds for the message to load.

Running PHP 7.4.3 on Ubuntu 20.04.1 LTS

Note that in this email it's retrieving a URL of https://cdn.etrade.net/1/1d/aempros/etc/designs/smartalerts/styles/smartalerts.css.  If you go to that site it takes a fraction of a second to load, but when this call pulls the same external stylesheet it takes 5 seconds.  I have the same issue when my kids school sends me an email which has an external stylesheet of https://storage.googleapis.com/static_pl/css/email.min.css in it. 

I've yet to find an email which is fast which calls modcss.inc, so I suspect this is some sort of issue with how external stylesheets are being retrieved.  The interesting thing to me is that this problem exists solely in file_get_contents(), which is a native PHP call...