I’m trying to render a page in HTMLViewer that has a moving background and a few animations. I need to use native rendering due to CEF limitations. When I view the page in IE it uses less than 1% CPU, but viewing the same page in a Xojo HTMLViewer, my CPU usage skyrockets to ~24%. I checked the profiler - there is nothing else going on in the program. Altogether it used 24ms time to do all the Xojo code over 15 seconds. Any ideas why the HTMLViewer would be taking up so much CPU and how to improve it?
Which engine are you using…Native or WebKit?
You may want to try the same in the Microsoft Web Browser active X control.
To use in your project, go menu Insert, then select Active X Component, then select Microsoft Web Browser. It will place the class in your navigator, then all you have to do is place it on the window.
The methods, events and property differ from the HTMLViewer, but autocomplete is your friend.
You can also find the information on the control at https://msdn.microsoft.com/en-us/library/aa752043(v=vs.85).aspx
To load a page, do for instance :
me.Navigate("http://fontmenu.com")
I am using the native rendering. I think that may be using the WebBrowser ActiveX control. In any case, I tried out your method and it’s the same high CPU usage. This is really odd though - when I run in IE there is nowhere near that level of CPU.
CPU usage is also considerably lower with WebKit rendering, but the problem there is WebKit doesn’t support common audio/video file formats. Unless someone has a solution for that?
[quote=225076:@David Barese]I am using the native rendering. I think that may be using the WebBrowser ActiveX control. In any case, I tried out your method and it’s the same high CPU usage. This is really odd though - when I run in IE there is nowhere near that level of CPU.
CPU usage is also considerably lower with WebKit rendering, but the problem there is WebKit doesn’t support common audio/video file formats. Unless someone has a solution for that?[/quote]
HTMLViewer Native rendering is not the same as the Active X component. Both use the same renderer, but the Microsoft Web Browser is the unwrapped control. It may behave closer to IE and be less demanding in resources.
According to HTML audio tag and HTML Video Chrome which uses WebKit supports all three formats listed. You may want to give these a try.
Unfortunately, this does not seem to be using much less in resources. I don’t think it’s the same rendering engine as the actual IE browser. I think I read somewhere a while back that Windows basically ships with two browsers. There is the OS browser used in File Explorer, Control Panel, and some other places, and there’s Internet Explorer.
Chrome supports mp3/mp4/etc, but the Chromium Embedded Framework used by Xojo does not. This is a licensing restriction. MP3 and MP4 are proprietary formats and so they were left out of CEF. There are some Xojo threads on this where it seems people concluded you have to use native rendering.
I did not realize Xojo WebKit was so limited.
For sound you can use CancelLoad, get the file with a socket, and play it in Xojo. But that is cumbersome.
The Xojo HTMLViewer control uses the default rendering engine, which I believe is equivalent to IE7 or IE8 depending on what OS you are running. You can use some tricks to get that up to IE11. That could explain the difference between what you see in the HTMLViewer vs. just running in IE.
https://forum.xojo.com/27089-64-bit-webkit-on-windows for a longer discussion.
Personally, I find that the IE11 engine is quite good and usable with standard HTML5/CSS/JavaScript techniques.
Is there a way to summarize what was said in this discussion? It seems it is only viewable to a few select.
Here are some links. The gist is that you can either put special meta tags in the HTML (if you control the HTML) and you can also set a key in the Registry.
http://www.realsoftwareblog.com/2011/01/changing-htmlviewer-rendering-mode-on.html
and
http://blog.xojo.com/blog/htmlviewer_engines_on_windows
are two good links
We finally got to the bottom of this issue after much investigation. This has nothing to do with IE7 compatability. We were already using a meta tag to solve that based on what was in the forums. In any case, IE7 mode does not affect performance much if at all. It is a huge impediment to using newer technologies like CSS3, however.
The real issue is for some strange reason, the embedded native browser does not use GPU rendering by default. IE does, but the embedded browser does not. You can enable it using a registry key. See GPU rendering here.
https://msdn.microsoft.com/en-us/library/ee330731(v=vs.85).aspx
The following code in App.Open worked beautifully for us. CPU usage went down to the single digits (from as high as 80-90%), and all the animations look smooth.
Dim reg As New RegistryItem("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft")
reg = reg.AddFolder("Internet Explorer")
reg = reg.AddFolder("Main")
reg = reg.AddFolder("FeatureControl")
reg = reg.AddFolder("FEATURE_GPU_RENDERING")
reg.Value(App.ExecutableFile.Name) = 1
Interesting: I wonder if this is relevant with IE10 or IE11 browser engines too? Or is just applying to IE9…
I found out not long ago that the default Windows 10 IE11 is using IE9 mode…
It is time to go Edge (not over the