Welcome Guest Search | Active Topics | Sign In | Register

Hangs Loading of Interface (WinForms) Options
GUGK Torbjörn Nilsson
Posted: Monday, September 28, 2020 8:04:51 AM
Rank: Newbie
Groups: Member

Joined: 9/28/2020
Posts: 2
Hello!

I have been working with your Controls (WinForms) for some while using both WebBrowser and PDF components in our HMI application (C#, .Net 4.6.1, WinForms), for machines (actual automation machines with servos, vision-cameras, lasers and other cool stuff :D) that we build.

The WebBrowser-Control is used to show the PLC HMI which is accessed using HTTP and delivers HTML5.

The PDF-Control is showing CAD Drawings in PDF-format to the operator explaining how to handle a specific product.

Now! The issue I have is that the startup of the interface is hanging for about 2 seconds before showing the complete interface as it should. I always thought it to be a issue with me doing a lot of binding and loading of data during the loadsequence. But now when I'm coming aroud to handle this small but irritating issue I find after some investigation the the whole situation is resolved if I just set the WebBrowser-Control to Visible=false (Still doing the loading but just not showing it).

I have a large project with many thousand rows of code, so just to test this theory out I made a supersimple WinForms-project with one TabControl, and three tabs:

1. A lot of standard WinForm Controls (Buttons, CheckBoxes, ComboBoxes, GroupBoxes and so on...)
2. PDFViewer
3. WebBrowser

So if you do the same in this order and start the application you will notice that the TabControl is showing the same instance that the form is showing! Perfect! as expected.

If you now change the order of the tabs to that one of the EO-controls are the first control you will notice that the TabControl is not showing until about 2 seconds after the form is opened.

And in this test I do not even try to load anything in the controls, its just showing them. (I did not a single line of manual code in my testproject)

Also, if you go back to the first setup with the standard controls as first TabPage and just click on any of the other tabs it will hang the update of the control for about the same time (2sec)...

Do you have a workaround or pattern to make it load async that let it initialize without freezing the interface?

I just downloaded the latest version (20.2.63.0) to make sure it was not fixed already, but its the same...


Best regards
Torbjörn Nilsson
eo_support
Posted: Monday, September 28, 2020 9:56:48 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

This is normal. The delay occurs when the browser engine initializes, which only happens if:

1. When a WebView's parent window has been created. This is what caused the difference in your case;
2. If you use HTML to PDF converter, when your use HTML to PDF to start the first conversion;

When you use a PDFViewer, it actually falls to the first case because internall PDFViewer uses WebView. Note that the browser engine used by case #1 and case #2 are different, which means starting the browser engine for case #2 won't solve problems for #1.

One way you can optimize this problem is to initialize the browser engine early. For example, you can call this code as soon as your application starts:

Code: C#
WebView.Preload("about:blank");


Or you can use a new ThreadRunner to create a empty WebView completely in the background thread:

https://www.essentialobjects.com/doc/webbrowser/start/webview_no_ui.aspx

Both methods will intialize the browser engine thus by the time you really need the WebView in your UI, the engine is already initialized thus you won't notice much delay.

Obviously this only works if you do not need the browser engine/WebView right away.

Thanks!
GUGK Torbjörn Nilsson
Posted: Tuesday, September 29, 2020 2:07:07 AM
Rank: Newbie
Groups: Member

Joined: 9/28/2020
Posts: 2
Perfect!

The preload solved the problem! Thank you!

Best Regards
Torbjörn Nilsson
eo_support
Posted: Tuesday, September 29, 2020 6:22:10 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Great! Please feel free to let us know if there is anything else.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.