Firefox page sometimes loads forever, how to determine cause? - debugging

Pages on my website sometimes load indefinitely (shows the circular blue loading animation in the tab, and "Waiting for example.com..." in the status at the bottom) in Firefox. Usually they finish loading very quickly.
Since I can't predict when it will have one of these episodes, and Firefox requires you to refresh the page in order to use the Network tool, how can I determine the cause of this on the rare occasions I see it?
I'm not sure if it is because JavaScript is running or a request for another file hasn't been answered.
This may happen in other browsers, but I generally only use Firefox unless the QA person I work with tells me there is a browser specific issue.

Generally, use the httpfox add-on, Firefox developer tools, and Firebug. Understand your server software and make sure errors are logged. Read the log.
If you can repro the error then you should be able to use a debugger with your server and find the section of code that is processing forever. Maybe there's an infinite loop. Maybe a lock has blocked execution. Maybe a ridiculous query was made to the database.
Otherwise, unless this unpredictable error is causing you to lose money or endanger people, ignore it.

Related

In which circumstances a websocket connection will close or re-open

I use many web applications everyday. I noticed some apps seem better than others at keeping the WebSocket connection active and to give instant feedback. If I am looking at others tabs, some web site will instantly indicate in the tabs' list that I received a new message, while some other will take more time or require me to get back to the window. Some websites are not consistent: sometimes they will give an instant feedback, sometimes I will have to refresh. I noticed often a website won't even be consistent across the multiple tabs I opened of it: Some tabs will notify that I received a new message, some other won't.
I would like to understand the rules that determine in which conditions my WebSocket connection will close or reopen by itself. Seems quite complex, since so many web apps are getting it wrong. Yet, I failed to find those rules.
I made all the searches I could think about. I can't believe that question has not been asked on StackOverflow yet. MDN does not say much, and even the specification have not been helpful. It seems the WebSocket connection will close by itself when I close the tab. It shows the connection will close automatically in some circumstances. Yet, even that behavior seems not to be documented. The specification only says something vague about the status code 1001 and "browser having navigated away from a page", but I've not seen anything about the browser being responsible to call "close" with that value. It makes me think all of this might be browser-defined. Yet I still need to know what to expect among the main browsers.
Any of you can tell me more on the matter?
Thank you

Selenium hanging and timing out on basic page interactions on OWA.

I'm using Selenium with a local FireFox browser to access live.com's spam box and read the email. For testing purposes, I've been using "binding.pry" to interact with my script and see where the problems are.
When I try to find the element representing an inbox message:
driver.find_element(:css,"#messageListContentContainer .ia_hc")
I get this error after 60 seconds:
Timeout::Error: execution expired
from /usr/lib/ruby/1.8/timeout.rb:64:in `rbuf_fill'
But, as I'm in Pry, I can quickly repeat the same command. After about 5 or 10 seconds, it finds the element.
Obviously I can get around the problem by putting a before, rescue, retry block around the call, but that means I'll have to wait 70-80 seconds to click a single email. Does anyone have any idea why find_element is taking so long that it times out, or why it doesn't time out the second time? Is it because the live.com (called "Outlook Mail" on the website) has a huge ammount of elements to search through? Is it something with the JavaScript they are using?
I've been able to duplicate this issue with both Firefox and PhantomJS
UPDATE:: I've found this is happening with all of the calls after any page refresh. I can call driver.page_source and I have the same problem. It seems selenium can't interact with the browser for a certain period of time after the page has refreshed. Could it be that selenium is having trouble reading everything off of the web page?
I have seen this happen in my own tests, but on an intermittent basis, and never completely reproducible. What seems to happen is that Selenium WebDriver just becomes blocked and unresponsive.
I know that I have just had to resort to rescuing the error, logging, and retrying in my code. After a few retrys, Selenium WebDriver seems to become responsive again and I'm able to continue on in my tests from there.
I have contacted the maintainer of the Ruby WebDriver gem, and he needs a reproducible test to be able to do some solid debugging. If you are able to provide a reproducible test case, please share it with us so that we can look into this issue. You can use this gist as a starting point to share with the community.
The problem just magically disappeared. It's not happening anymore and I can't duplicate it. Best of luck to the selenium crew finding it, it seems to come and go randomly.

Slow javascript execution in chrome, profiler yields "(program)"

How would I go about determining what the hangups are in my javascript app when the profiler puts (program) at the top with 80%? Is my logic too complex for the hotspot tracking to occur? Is my memory footprint too big? What is generally the cause of this?
More Information:
There are no elements on the form save the one canvas tag
There are no waiting communications (xhr)
http://i.imgur.com/j6mu1.png
Idle cycles ("doing nothing") will also render as "(program)" (you may profile this SO page for a few seconds and get 100% of (program)), so this is not a sign of something bad in itself.
The other thing is when you actually see your application lagging. Then (program) will be contributed by the V8 bindings code (and the WebCore code they invoke, which is essentially anything: DOM/CSS operations, painting, memory allocations and GCs, what not.) If that is the case, you can record a Timeline of your application (switch to the Timeline panel in Developer Tools and press the Record button in the bottom status bar, then run your application for a while.) You will see many internal events with their timings as horizontal bars. You will see reflows, style recalculations, timers fired, GC events, and more (btw, the latest Chromium versions have an improved memory profiler utilization timeline, so you will be able to monitor the memory used by certain internal factors, too.)
To diagnose memory problems (multiple allocations entailing multiple Full GC cycles) you may use the Profiles panel. Take a heap snapshot before the intensive part of your code starts, and another one after this code has run for some time. Then compare the two heapshots (the right SELECT at the bottom) to see which allocations have taken place, along with their memory impact.
To check if it's getting slow due to a memory option use: chrome://memory
Also you can check chrome://profiler/ for possible hints of what is happening.
Another option is to post your javascript code here.
See this link : it will help you in Understanding Firebug profiler output
I would say you should check which methods taking %. You can minimize unwanted procedures from them. I saw in your figure given some draw method is consuming around 14% which is running in background. May be because of that your JS loading slowly. You should determine what´s taking time. Both FF and Chrome has a feature that shows the network traffic. Have a look at yslow as well, they have a great addon to Firebug.
I would suggest some Chome's auditing tools which can tell you a lot about why is this happening, you should probably include more information about:
how long did it take to connect to server?
how long did it take to transfer content?
how much other stuff are you loading on that page simultaneously?
anyway even without all that, here's a checklist to improve performance for you:
make sure your javascript is treated and served as static content, e.g. via nginx/apache/whatever directly or cdn, not hitting your application framework
investigate if you can make use of CDN for serving javascript, sometimes even pointing different domain names to your server makes a positive impact, e.g. instead of http://example.com/blah.js -> http://cdn2.example.com/blah.js
make sure your js is served with proper expiration headers, don't re-download it every time client refreshes a page
turn on gzipping of js content
minify your js using different tools available(e.g. with Google closure compiler)
combine your scripts (reduces the number of requests)
put your script tags just before
investigate and cleanup/optimize your onload and document.ready hooks
Have a look at the YSlow plugin and Google PageSpeed, both very useful in improving performance.

Monitoring Hosting Performance

I've been building a site, running Wordpress 3.2.1 and noticed
the performance is sluggish in the front and back end.
I believe the problem is hosting specific.
The problem seems to be the connection loading the actual HTML
which is taking about 5.5 seconds. It appears to finish after
about 500ms, but does not stop loading for 3-4 more seconds.
Here is the development URL:
http://d1001488.u57.ukisp.com/dev/
Hosting:
Windows NT
PHP Version 5.2.10
There are a couple of jQuery select boxes that get
replaced and styled onload (in the footer), these take a
long time to get replaced after the page fully loads.
The hosts are claiming all is running properly. Is there
any thing I can try and tweak or monitor to see what
is going on? Or any suggestions?
Thanks.
For largely extrinsic causes, try YSlow. This will identify a number of things you can work on. It won't tell you anything about the internal behavior of your server, but it may help you narrow down what's going on.
The problem may be a specific plugin. Here's what I would recommend:
Try going through each plugin, deactivating it, and see if that makes your site load faster. Do this for each plugin, and if a deactivated plugin doesn't improve performance then just reactivate it and move to the next one.
Try temporarily activating the default Twenty Eleven theme. See if the default theme loads faster. If it does, then we can look at your custom theme.
These two things may help narrow down at least where the problem is coming from. Let me know how it goes!
Do you have CPanel access with your hosting account? If you do, look in the left side toolbar at the bottom you should see where it says server status (click to view) you will see various details about your server performance.

Firefox cache bug

This is a bug/issue which has cost my time for at least 3 years now.
I have complex, dynamic pages in ASP.NET which use a lot of javascript (which is more or less static).
Now I have a behaviour which happens only in Firefox and then only every few 10.000 requests.
Users are playing games on my site so they are hitting the same page again and again, every day. And then the game locks up with javascript errors on the page. I have never been able to find out what exactly happens. A file is corrupt perhaps?
Shift-F5 or simple reloading does not help. If the user clears his cache, the problem is gone.
This has been reported hundreds of times now. Every time the user has been a Firefox user, every time, clearing the cache fixed the issue.
I can't nail down the bug since I can't reproduce it.
There are lots of reports that Firefox is caching files which it shouldn't cache. But that doesn't seem to be the issue in my case. Something else is going on.
Anyone got an idea what's going on?

Resources