Open tanius opened 9 years ago
Initial profiling results:
All of the above curCSS calls are due to a single line of Annotator code in Annotator._setupDynamicStyle
, namely annotator.coffee:160
:
max = Util.maxZIndex($(document.body).find(sel))
This is used to find the maximum z index used in the page, in order to make Annotator display above it. For a known environment like Drupal, this is surely not worth 40% of execution time, so let's get rid of this.
(Hint: The internal profiler in Firefox often does not work properly, and the Firebug integrated profiler cannot be set active before page load. However, in this case it is enough to activate it once the first part of the page arrives.)
Profiling results after the change proposed above, on the same test page:
Total JavaScript execution time is now 68% less / 3x faster. That should suffice! Also, the remaining JavaScript functions do not noticably interfere with Firefox responsiveness to user input.
Fixed for now. Remaining work: find a cleaner solution. See the code comment from the last commit.
This problem still is very noticeable with Firefox when visiting group index pages (where all the group's posts etc. are listed on the bottom). Esp. when the group has a lot of content. Not sure how that happens, maybe this "Commons group browsing widget" only shows the first page but pre-loads all pages in the pages in the background, which would entail creating Annotator instances on all of them, too.
To be fixes when there is some time for it, since so far nobody except me complained.
Chrome is slow too. I think this is not so serious, because normal users of ER are not affected, and researchers need time to think anyway. That leaves us (site admins): we normally do not code, and spend a lot of time on the platform.
Two workarounds that I can think of. Both involve Drupal permissions management. The first one goes as follows
The second workaround:
Both workarounds can be implemented simply from the Drupal admin interface, no coding involved.
@tanius what do you think?
These workaround would work, yes … yet if the speed issue is only about the group browsing widgets now, it seems cleaner to modify them (loading all content in the background is no good idea anyway). After all, the current set of optimizations should make OpenEthnographer closer to be usable by everyone else as well, so it makes sense to invest a bit more than what's needed for workarounds.
Another option is a user profile option where every user with access to OE can choose if they want it loaded or not.
While in Chrome there is no noticeable difference when creating Annotator instances (without any annotations in them) for 30 fields on one page, Firefox might take 15-20 s of high CPU load to process this, until becoming responsive again (system: Core i7 2 GHz). So this is an issue of the slower JavaScript engine in Firefox – it is much slower in some functions, and instantiating Annotator seems to rely heavily on some of these.
Solution proposals, by current degree of favouring them:
annotator
andannotation
Drupal plugins is required to get it to work. Also, third-party Annotator plugins will not support 2.0 initially, but that is less of a problem as we only use Annotator core plugins (Tags, Store, Permissions) and these are mostly supported.Hints for debugging:
Annotator._instances
JavaScript array.jQuery("insert-your-selector").size() == 1
/annotation/api/search
. This is cared for in #42 already.