TWebBrowser control slow performance only in Delphi - performance

Can someone explain me why TWebBrowser control is working so slow on all XE editions of Delphi including XE5 and possibly XE6? To test this you need to create a new Delphi project and put TWebBrowser control in it. On form show event, navigate to this website:
http://ie.microsoft.com/testdrive/Performance/setImmediateSorting/Default.html
Please test this on Windows 7 or later. When navigation is complete, run setImmediate test and watch the results. It will take huge amount of time to complete the test. It will take about a minute to finish this.
When you open true Internet Explorer browser and do the same thing - test will be completed instantly (~200 miliseconds).
Some additional wierd informations:
When you recreate this procedure on old versions of Delphi (Delphi 7 to be precise) the web-control works as fast as it should be working and test is completed instantly. But the HTML5 speed test will still works slow (alternative test on this page).
Another weird thing is, the same slow behavior can be seen on C++ Builder but not in Visual Studio products. Is Microsoft deliberately slowing down the TWebBorwser in Embarcadero products?? I can't belive this.
I was trying to overcome this problem with diffrent methods such as:
Trying different feature options in registry such as:
FEATURE_GPU_RENDERING,
FEATURE_BROWSER_EMULATION (11001),
FEATURE_ALIGNED_TIMERS (undocumented option),
FEATURE_ALLOW_HIGHFREQ_TIMER (undocumented option),
Setting timerBeginPeriod(1) - no effect.
Please, if someone have any clue how to fix this issue - share this information with me.
UPDATE1
I made standalone test app if anyone cares. It can be downloaded here: http://mp.org.pl/download/ietest.zip It contains source and exe app with htm file. HTM file contains some js procedure that works 10 times faster in standalone IE than in TWebBrowser control. It uses setImmediate as a test (the same procedure used in test described above). But it can be easier for testing this way.

I can also see the behavior described (in your original post and in the comments). I have a few thoughts, but not necessarily an answer.
One should expect some difference in performance between the WebBrowser control and IE, in part because your Delphi app will need to build in support for certain features/APIs that IE supports out of the box.
For example, the WebBrowser control fires notifications related to tabbed browsing (old, but relevant), but it does not intrinsically handle those notifications or update the UI. You have to respond to the notifications and draw the tabs yourself. By default, IE is hardware accelerated and uses certain Windows APIs that may not be directly supported by Delphi's VCL (for resource/performance) reasons. (Hardware acceleration could account for some of the performance differences you've noticed.)
(And, for the record, I don't believe a list of differences between IE and the WebBrowser control was ever documented. I certainly don't remember seeing one in the portfolio.)
Also, the default values for various feature controls vary between IE and applications hosting the WebBrowser control. Part of the reason for this stems from the idea that IE needs to highlight performance over compatibility whereas applications generally need to emphasize compatibility over performance. You may wish to review the feature control reference to see if there are other FCKs you need to enable for your app.
Second, your loops are very tight, perhaps too tight. You've got one request piling on earlier requests and you're not really leaving much room for processing, even with setImmediate. (IIRC, we're not really supposed to use anything smaller than 250ms for setInterval without risking performance hits from the sheer number of requests.) The remarks in the setImmdiate ref. page provide some guidance, as does this article on requestAnimationFrame.
One reason why dragging the window appears to improve performance may due to the priority of window drag repaint requests. They may be forcing your loops to hold long enough (or even break) to allow other events to process. Hard to say without with tracing the system with a debugger.
Have you ever had to add application.processMessages() to your Delphi apps in order to allow the system a chance to handle the work you've already assigned? A similar need may be coming into play given the nature of your test.
Performance testing and timing is a tricky thing. You need to make sure the test isn't imposing so much overhead that it interferes with the actual work you're trying to perform.
Finally, there were some questions about the document mode of the page as it's loaded into your project. When I first started messing around with your sample, I couldn't get project4 to load slowtest.html in anything other than IE5 quirks mode (notoriously slow). Here's what eventually started working for me:
<!DOCTYPE html>
<!-- saved from url=(0023)http://www.contoso.com/ -->
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<script type="text/javascript">
...
(Note, I deleted your initial doctype declaration and rewrite it to resolve a syntax error that was being reported by the F12 tools debugger.)
A few style key points here:
I used a mark of the web to load the page in the Internet zone. I find this makes it easier to load the page in edge mode, as pages in the intranet zone are loaded in compatibility view by default (unless you map the zones differently).
The x-ua-compatible header needs to be one of the first in the head block. It can follow title, but not much else.
Stylistically, elements need to be specified in lower case these days. There's a possibility that not following the current conventions forces the parser to fall back to an earlier rendering that supports the conventions.
Once I was able to control the documentMode at runtime, I found results I expected: older document modes ran more slowly. I also found that using requestAnimationFrame instead of setImmediate led to even better performance, but also surfaced the timing issue almost immediately.
In the end, this may be a case where the test highlights a problem, but not necessarily one you're trying to solve. (Insert Inigo meme here.) I get that you're trying to resolve a bottleneck. Are you sure you've found the correct bottleneck?
You may not be able to replicate the same performance of the native browser, but perhaps you can refactor the code to perform adequately without the extra overhead? Is there anything that might be better handled with a worker or some other implementation technique?
Hope this helps...

Related

ReactJS heavy load application performance issue

I am looking for some advice on how to track application performance; the application is developed using ReactJS, and I am building it with webpack.
First of all I will just present what I have done and what the application is expected to do:
I need to render a lot of, let's just call them widgets, that update real time presenting a lot of data. So, on a scale, I would say each widget renders about 50 to 80 values, these updates might be received from the server side all at once, so they should happen instantly when data is received. Consider I might have around 25 to 30 widgets that need to update real time.
Let me tell you a little bit about the implementation:
I have used the smart/dumb pattern for ReactJS components
The actual data is stored in application state and is distributed by the smart components to dumb components through props
I am using Pure Render Mixin to avoid unnecessary rendering
Also using Immutable data so that I will ensure Pure Render Mixin is working accordingly, that is, being accurate in determining if a render is necessary and at the same time be fast, really fast.
There are no weird bindings of callbacks, that might determine re-rendering of components, this is double checked already.
Now the issues I am having:
with about 5-6 widgets, meaning around 400-500 values that need to render each second, it works very well in Chrome and decent in Firefox.
adding about 25-30 widgets gets the application to still work decent in Chrome, but it starts to act slow in Firefox, by slow I mean user interaction that might even get a delay of around 1 second. That is really unacceptable.
What I have tried:
use Chrome dev tools to measure the performance; that didn't help too much, what I could see though, is that everything is alright. And there is no way I could read all the graphics this tool provides. (And I've read a lot of articles about it)
tried to use Firebug in Firefox. That's an amazing tool, but not in this case; just by opening it with the above mentioned load (30 widgets) gets Firefox to freeze... and the profiler gave me nothing)
on a last resort, I have used the default dev tools from Firefox, it has a performance tab. That got me some information of what parts of the application has the most load on the browser. It seemed it was some heavy computing determining min/max of an Immutable.List.
Unfortunately the application still has performance issues, and it is of high importance to get it working perfect, and Firefox profiler doesn't give me any other leads.
So my questions would be:
what would be the next action to take in order to determine performance issues? (as much as possible where they are: class/method/at least file)
did you guys use any performance testing tool that gives you an insight of what the hell is happening?
is there something else to consider to improve the overall functionality, especially targeting multiple browsers? (Firefox, Chrome, IE11)

How, as a programmer, to report bugs I find in core Gecko browser-engine behavior in Firefox

When I’m programming a Web app and I run into a problem that only seems to happen in one browser, I know that a somewhat-essential step among my overall programming tasks as a “good citizen” is to stop coding for a bit and take time to report the bug in the right place—so it can get fixed and other Web developers (including me) hopefully won’t run into the same problem later.
In such cases with Firefox, I understand enough to know when the cause of the programming problem I’m seeing is in the core “Gecko” browser-engine code in Firefox (rather than instead being, say, a bug in the Firefox user-interface code—the code for the so-called browser “chrome”).
Given that, is there a URL that will take me directly the form where I can quickly get to the right bugzilla “product” and “component” to report a Gecko browser-engine bug against?
Having already reported a few bugs in the Gecko code, I am somewhat annoyed at being forced to use the form at https://bugzilla.mozilla.org/enter_bug.cgi, which seems to assume I’m reporting a bug for the first time and I want guided step-by-step help. But this ain’t my first barbecue…
https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&format=default is the URL you want.
That’s because in the case of Firefox, the right bugzilla “product” to use for browser-engine (Gecko) bugs is actually Core (not the Firefox component—and there is no Gecko component).
That URL above takes you directly to an actual bug-reporting page—that is, as you’d want, it completely skips all the designed-for-first-time-bug-reporters step-by-step guided-help stuff.
You do need to then manually choose the right “component” from the Component list there, but if you already know the right component, you can make a bookmark that includes it; e.g., https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&component=DOM%3A%20Workers&format=default is a URL that will let you report problems with Firefox Web-Workers behavior.
Adding the &format=__default__ parameter/value is the important part needed to get bugzilla to skip all the designed-for-first-time-bug-reporters step-by-step guided-help stuff.

IE takes too much time to load the page compared to Firefox

I have a page which displays around 1000 records.
The page gets loaded quite easily on firefox..around 2 seconds. But same on IE taking more that 10 seconds.
I checked performance tuning on server side, and modified the hibernate Criteria query returning this whole data. But issue is still there.
I also tried to remove almost all the plugins from IE thinking those could be the culprits. But no impact. :(
Trying to monitor the UI components on IE developer tool, but didnt find much details.
Any suggestions please. :)
Thanks in Advance :)
Performance issues like this will be down to rendering the UI. The server side processing won't vary from browser to browser, so it will be down to the way different browsers handle the drawing of the elements. Without seeing your page in action it is not easy to suggest anything to help improve your situation.
Guys Got the Culprit here... :) :)
After doing lot of RnD on Server side and Client side, I took a look at "Developer Tool" in IE.
You can find something like "Document Mode: Quirks". If you check the Wiki page for this Quirks mode, You can find a definition as "In computing, quirks mode refers to a technique used by some web browsers for the sake of maintaining backward compatibility with web pages designed for older browsers, instead of strictly complying with W3C and IETF standards in standards mode."
So this all becuase of checking for compatibility for all components on page. And hence the performance issue. :)
And When I changed this mode to IE 8 Standard. Things started working really well.
IE and its issues ...!!!! :D

Why Are Automated GUI Tools So Fragile?

For about a year a half, I've been working with SilkTest, which is a GUI automation tool, for both desktop and web applications. It simulates mouse and keyboard inputs, which eventually simulate end user behaviour. However, I find that it is a bit flaky; Button.Click() or DialogBox.Close() method calls that work just fine 9 times in a row seem to fail on a 10th call, only to go back working on the 11th. Normally I would just chalk this up to a quirk with SilkTest (or the application under Test, or the OS, or what have you) but then I see that there are similar issues with other GUI automation tools like Selenium:
Selenium Click() fails with Anchor Elements
Selenium Click() fails clicking button object
I know that for desktop apps, each GUI control/dialog has a tag element associated with it (at least in Windows-based GUIs) and that for web pages there is the domain object model hierarchy of page elements. My guess is that these tools sometimes run into issues navigating these hierarchies and finding unique elements and controls. But what is going on here? SilkTest is a relatively old, commercial software package while selenium is relatively new, open source and constantly evolving. The fact that they both can have similar problems raises a couple of flags with me.
Also, is this the case with other GUI test tools? Or have I just had a somewhat unusual experience?
There are 2 things here that you are talking about, first the concept of finding an object in the application under test that you want to automate. Your description of how SilkTest (and other tools) does this is quite accurate, i.e. as long as there is something that the automation software can use to identify the control then you are fine.
The second thing is why does the automation itself fails randomly, since the tool has not reported that it could not find the control then it must think that it sent the appropriate action to the application, e.g. a Click or a Type. This could be that the application is not ready to accept the action that you are sending it, this is similar to you attempting to click on something "before it was ready", in this case the application can decide to buffer the input or to discard the input.
So, how do you fix this? One way would be to use the capabilities of the tool to try to work out when the application is ready for input rather than sending it a stream of input blindly. SilkTest has capabilities that allow for you to do this (as does TestPartner). I cannot comment on Selenium as it is something I have not used.
A simple way of testing this would be to insert a pause for a couple of seconds before the offending action, then run this in a loop to see whether this solves the problem, if this is the case then it is your problem. If this does not fix the issue then there is something else going on that you need to contact the vendor of the testing tool.
Remember that applications are getting more and more complex, i.e. multi-threading, communications, any one of these could cause the automatic syncronisation to fail causing actions to fail.
Hope that helps.

How often do ASP.NET developers NOT use Visual Studio design mode?

We are developing an ASP.NET application. We retained an outside UI design firm, and for the most part have been very pleased with their work. Their "deliverable" to us was clickable screens -- Visual Studio solutions with ASPX files, images, master pages, etc. The screens were not connected to any data source. They had dummy data so that we could see how the UI worked.
One problem we've run into is that our developers are used to using Visual Studio design mode. The pages we receive from the UI firm have problems sometimes when we pull them up into design mode. The consultant's developers coded these screens without using design mode.
We assumed they'd be using design mode, but this wasn't specified in the contract. Was this too much to assume? Is there a lot of ASP.NET development work that never goes through VS design mode?
Third party edit:
Suggestion: people responding to this question should specify which
version of Visual Studio they're
using, as Microsoft trashed the code
base that was in the VS2005 and
earlier designers, and replaced it
with the one they purchased when they
purchased the Expression products. The
two are totally unrelated, and the new
one is far better. - John
Saunders
The more and more you work with Visual Studio, the less and less you rely on Design Mode. Complicated UIs tend to make the design view look atrocious.
I (and peers) never use Design Mode, for two reasons:
I learnt in VS 2003 not to touch Design Mode because your HTML was managled by VS. (Not anymore though since 2008, but once bitten ...)
It can take ages to render.
Much quicker to drag-drop from toolbox and hand-code.
I actually find that ASP.NET developers that do use the designer to be quite rare. The Visual Studio designer is notoriously bad at generating clean markup.
I never use design mode, probably because it used to mess my markup so much. Plus I do a lot of dynamic rendering, so there is no point. And I use exclusively CSS for formatting, I don't want VS messing around.
Many never use it, because of bad past experiences. I have found little trouble with Design mode in VS2008, when using modern controls, which are up to date and have good designer support.
On the other hand, because of the earlier problems, a lot of custom server controls do not have good designer support, so are much less useful in design mode now that the earlier designer code base has been replaced with a good one.
I almost never use design mode. It typically creates ugly HTML, and call me anal, but I really like to have clean HTML. If that means hand-coding it, so be it.
I prefer doing it manually, I like to have control.
If I want to look at the result, F5.
I almost never use design mode. For me, the biggest reason is because I learned web design/development in Notepad, so I was used to (and comfortable) working with code. Design mode makes me uncomfortable because I'm never sure exactly what decisions VS will make with regard to HTML, etc. Additionally, I can't imagine that a developer would learn nearly as much about ASP.NET and VB/C# using design mode.
The only time I use design mode is to automatically configure a GridView or something like that like.
Design Mode is taking quite a beating here, but let me point out that it is great for learning about new controls. When you are new to ASP.NET, or are using a new library of controls, Design Mode is a godsend for two reasons:
You can modify properties on the Property Editor and see them reflected immediately. This is particularly true for list-container type controls, where the entire layout may depend on one property. Running your application five times to see all five layouts is very tedious.
Controls with complex behavior (and lets face it, thats why you're using a control, right?) often have a lot of configuration built into their Smart Tags. Notice the little [>] arrow in the top right of the control? Click it. It'll probably help you out big time. This is particularly true for configuring DataSources, whose syntax is very meticulous.
When I was first learning to use Telerik controls, I relied heavily on the Smart Tags they provide, which are very robust and complete. From that, you can see what kind of ASPX markup is generated and learn to work outside of Design Mode. I am a learn-by-doing kind of guy, so I much prefer this approach to looking at the documentation when using something for the first time.
I'm using VS2008, and I never use the design view. I find the code view to just be easier and more responsive than the designer.
Y'know, I never even realised I use the source screens 100% of the time. I usually develop in VS2005.
Whenever I do actually open the design mode, it's by accident, and I try and hit the source view before it renders. I've never been impressed with the design mode, and find it slow as well as adding a lot of unnecessary markup. I also find that intellisense and the properties window mean that I don't need a GUI to develop.
The design mode can also be a nightmare when you're trying to add any nested items. Because we've been developing for a customer using IE6 we've been using tables for formatting so we don't need different DIV definitions. Just clicking in an empty cell can be difficult, and resizing a column can take far too long.
For things like Template Fields in grids, I don't even know how I'd go about setting this up in design view!
Having said that, design mode every time for windows apps!
Design mode is getting better and I'd say that it's likely to become more prevalent as time goes on and the design mode tools continue to improve. I design all my components for design mode, but I still do the large majority of my code by hand - it allows greater control of code layout and doesn't end up creating an auto-formatted mess that I then have to dig through to figure out what changes need making. I know that in future my components are likely going to be used by developers that do most of their design by drag/drop and it's easier to cater for that now than have to come back and do it after the event.
Granted I'm doing MVC stuff, but I never use it - I "grew up" with PHP and code editors, and it still does me just fine.
I'm using two different versions of .NET (2003 & 2005). Some of the forms that were written in 2003 can no longer be edited in 2003 and the installation requires that they be maintained in 2003, so I use KEDIT to edit those forms.
Some of the forms in one application are too big for the .NET editor and I prefer a strong editor anyway.
I have no problem working in design mode. One exception is asp:Repeaters, which are not supported, or GridViews which tend to override my manual column definitions.
The other is if VS tries to do a full project scan if I rename a control, and then fails.
We primarily use the code view. The design mode is quite buggy we've found in VS 2008. XML controls tend to barf random character sets out for some reason, and VS will generally run slow whilst trying to render everything on screen. I mainly use the code-view.
Traditionally WYSIWYG designers produced poor code and render CSS and #INCLUDEd files poorly so they were of limited use, so developers tended to code by hand. In addition, these tools allowed you to go a certain distance without real knowledge of what you were doing, which was fine for web tutorials and personal homepages, but as soon as you wanted an extra degree of control you became unstuck - when meant you had to resort to looking 'under the hood' anyway.
Although tools have improved over time, many developers are so comfortable with hand-coding that they all but forget about the Design View - I certainly can't remember last time I used it. I'm sure there are a number of situations where such tools could be genuinely useful, but we are doing fine without and don't want to be bothered with figuring when & where such features can best be used.
Our UI is complicated and it is impossible for us to use design mode with VS2005.
The only time I have touched design mode is to do a quick and dirty prototype or an internal app.
How often do I not use design mode? 99% of the time.

Resources