[MAGNOLIA-283] javascript hangs firefox (cpu at 100%) during admin operations Created: 06/Feb/05  Updated: 23/Jan/13  Resolved: 13/Feb/05

Status: Closed
Project: Magnolia
Component/s: admininterface
Affects Version/s: 2.0 Final, 2.01
Fix Version/s: 2.1 Final

Type: Bug Priority: Blocker
Reporter: Fabrizio Giustina Assignee: Fabrizio Giustina
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

firefox 1.0, windows Xp


Attachments: Text File profile_delete.txt    
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Firefox 1.0 on windows has some problems with many operation in adminInterface.
Trying to:

  • delete a node
  • activate a node
  • copy a node
  • move a node
    makes firefox use 100% cpu for a long time (several minutes, if you try to activate a whole tree), making the system unusable.
    This doesn't happen on IE.


 Comments   
Comment by Fabrizio Giustina [ 06/Feb/05 ]

this is a profile obtained using the Venkman javascript debugger in firefox, showing the deletion of a node.

Two long-running functions are highlighted:
tree.js: mgnlTreeDrawNodes 425 seconds
tree.js: httpRequest 425 seconds

Comment by Fabrizio Giustina [ 06/Feb/05 ]

the problem is due to a sync XmlHttpRequest.send call
see tree.js, line 1151:
httpRequest.open("GET",url,false);

the third parameter, set to false, makes the request happen in sync mode and the browser hangs.
Sync request should never be used in web interfaces, and should be replaced by async calls and callback functions.

See
http://jibbering.com/2002/4/httprequest.html

"Never use sync in a webpage

All the examples here use the async mode (the third parameter of open set to true), this is important. Whilst the object can make sync requests, it's very bad on the user - the UI locks whilst the request is being made, if the request is long enough, a windows user may even see the "Not Responding" message and decide to kill the browser. Since you can do everything you wish with the ASYNC mode, always stay with that, your users will thank you, and you're much less likely to run the risk of lock-ups when more than 2 dependant requests are made at the same time."

So, the above call should be fixed using:

// async call
httpRequest.open("GET",url,true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4)

{ var returnText=xmlhttp.responseText; // and now we need a callback... the hard task: // callback(); }

}
httpRequest.send(null);
return;

I am not really confident with magnolia javascript functions, so I can't do much more now... all the function using the send() method should be modified, removing expected return value and adding callbacks funtions.

This is IHMO a show stopper in magnolia, since it can't be used at all on windows firefox for big operations.
Can anybody familiar with magnolia javascript work on this ASAP?

Comment by Fabrizio Giustina [ 06/Feb/05 ]

wow, since httprequest() was used only in 2 places in the code I tried working on it.
I committed a fix on svn, works great on firefox and IE 6 windows, need to be tested on other browsers!

changes are in tree.js, marked with comments.
please review them

Comment by Andreas Weder [ 12/Feb/05 ]

Fabrizio, I've checked your fix on the 2.02 branch. Looks very good so far, thanks for addressing this issue.

Comment by Fabrizio Giustina [ 13/Feb/05 ]

tested and working. Committed both for the 2.02 and 2.1 branch.

Generated at Mon Feb 12 03:15:54 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.