|
Rank: Member Groups: Member
Joined: 5/6/2015 Posts: 25
|
Hi, i've a service that uses your control to callculate html to a picture. That works most time flawless. But sometimes it runs into timeout. Here is a part from my code (VB.NET) that i use to render
Code: Visual Basic.NET
Private Function FU_GenerateBase64(Loc_html As String, loc_width As Integer, loc_height As Integer) As String
FU_GenerateBase64 = ""
If Cloc_WebView.LoadHtml(Loc_html).WaitOne(1000) = True Then
Cloc_WebView.Resize(loc_width, loc_height)
Using Loc_Image As Drawing.Image = Cloc_WebView.Capture(True)
Using Loc_Bitmap As New Bitmap(Loc_Image)
Using ms As New IO.MemoryStream()
Loc_Bitmap.MakeTransparent(Drawing.Color.White)
Loc_Bitmap.Save(ms, Drawing.Imaging.ImageFormat.Png)
ms.Position = 0
FU_GenerateBase64 = System.Convert.ToBase64String(ms.ToArray)
End Using
End Using
End Using
Else
SU_Log("Timeout 1000 ms")
End If
End Function
the Loc_html is filled with a static html text with embedded css. No external sources. The Cloc_WebView is declared once and only destroyed at the end. My problem is how could i avoid the timeout ? What could cause the timeout ? At the moment i loop 3 times if i get no return. But that doesn't help every time.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, Please try LoadHtml(loc_html).WaitOne(3000) instead of looping three times with a 1000 timeout. Ocassionaly the browser engine can get choked up temporarily but if it does not resolve by itself eventually then it would indicate a problem. By keep looking and submitting new request would only make the matter worse. On the other hand, if you WaitOne(3000) but the request is done in only 10 ms, then the function will return immediately and wait no further. If that still fails often then there must be a problem somewhere else. In that case I would recommend you to wait until after tomorrow. We will have a new release tomorrow so you can try that build first. The build maybe posted later the day so depending on your time zone it may not be posted during your business hour. You can wait until the new release is out and then try the new release to see if it resolves the issue for you. If it still does not resolve the issue for you, you can try to isolate the problem into a test project and send us the test project. See here for test project guidelines: http://www.essentialobjects.com/forum/test_project.aspxOnce we have the test project, we will look into it as soon as possible. Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/6/2015 Posts: 25
|
I've tried to set up an test but failed to get the same result only got other strange behaviors. Anyway, i will use now the latest version test live.
Edit: Not at the moment -> licence problem
|
|
Rank: Member Groups: Member
Joined: 5/6/2015 Posts: 25
|
Now i've changed the timeout to 3000 and used the latest version, but the problem stays the same :( I have tried to build a test application but at the moment i don't have rebuild the error condition.
Some other ideas ?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, Have you tried using ThreadRunner class? As a general rule, you must run a message loop in your worker thread in order for a WebView to function properly in that thread. The ThreadRunner class is provided exactly for this purpose. See here for more details: http://www.essentialobjects.com/doc/webbrowser/advanced/thread.aspxThanks!
|
|
Rank: Member Groups: Member
Joined: 5/6/2015 Posts: 25
|
Sorry but the thread runner example doesn't compile. Error Imagelooks like the syntax doesn't work with vb.net
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Please change "Function" to "Sub".
Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/6/2015 Posts: 25
|
Hi, nope change to sub doesn't help Error Image
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, The sample code uses anonymous delegate syntax to call the following method and the code is valid: http://www.essentialobjects.com/doc/eo.webbrowser.threadrunner.send_overload_2.aspxBoth Function and Sub will compile in Visual Studio 2013 with .NET 4.5. Using Function you will get a warning because the anonymous delegate does not have a return value. If you have trouble getting the anonymous delegate code to compile, you can just use normal syntax by declaring the code you call with Send inside a separate Sub and then call it with normal delegate syntax. Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/6/2015 Posts: 25
|
I'v got it run with threadrunner. But now i have more problems cause the rendered image is the wrong. The Image is from previous attempt Cloc_threadRunner and Cloc_WebView are class declared trans_html content:
Code: HTML/ASPX
<html>
<head>
<style>
tr.xx3 {background-color:#E13C00}
tr.xx1 {background-color:#8CFFA0}
body {background-color:#D8D9DA;font-family:Arial,Helvetica,Swiss;margin:0px}
td.mittel{font-size:20px;font-align:center}
td.klein{font-size:10px;font-align:center}
td.gross{font-size:40px;font-align:center}
td.sehrgross{font-size:60px;font-align:center}
td.Leerzeile{font-size:60px;}
</style>
</head>
<body>
<table border=0 cellpadding=0 cellspacing=0 Width="100%">
<tr>
<td class="Leerzeile"> </td>
</tr>
<tr class="xx1">
<td class="gross">SOLL: </td>
</tr>
<tr class="xx1">
<td class="sehrgross">Test1_02</td>
</tr>
<tr>
<td class="Leerzeile"> </td>
</tr>
<tr class="xx1">
<td class="gross">SCAN: </td>
</tr>
<tr class="xx1">
<td class="sehrgross">2</td>
</tr>
</table>
</body>
</html>
Code: Visual Basic.NET
If CType(Cloc_threadRunner.Send(AddressOf FU_Render, Cloc_WebView, trans_html), Boolean) = True Then
Using Loc_Image As Drawing.Image = Cloc_WebView.Capture(True)
Using Loc_Bitmap As New Bitmap(Loc_Image)
Using ms As New IO.MemoryStream()
Loc_Bitmap.MakeTransparent(Drawing.Color.White)
Loc_Bitmap.Save(ms, Drawing.Imaging.ImageFormat.Png)
ms.Position = 0
FU_GenerateBase64 = System.Convert.ToBase64String(ms.ToArray)
End Using
End Using
End Using
Else
SU_Log(ENU_Log.Fehler, "Timeout 3000 ms")
End If
Function FU_Render(trans_webView As EO.WebBrowser.WebView, trans_args As Object) As Object
Return trans_webView.LoadHtml(trans_args.ToString).WaitOne(3000)
End Function
i've removed the threadrunner and use LoadHtml( ).WaitOne(3000) direct but now the routine waits every time 3000 ms :(
|
|
Rank: Member Groups: Member
Joined: 5/6/2015 Posts: 25
|
Ok i've update to the last version 2015.1.84.0 the long waiting is fixed. But at the moment when i'm capturing the image direct after .waitone i got the previous image.
i've fixed it with called it twice and then capture the image but at least i get the correct image.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Yes. You will need to wait for a little bit after WaitOne completes. The reason is WaitOne returns as soon as the loader finishes loading. There is a small time delay between loader finish loading and screen buffer is refreshed. We may add something like "RefreshScreenBufferNow" in the future. But for now you can try to wait for a short period of time (for example 200ms) and see if it resolves the issue for you.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/6/2015 Posts: 25
|
Ok, then i will wait for RefreshScreenBufferNow or something equal.
Looks like rendertime for one image is about ~45ms. Twice rendering works during testing here whole time.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Great. Glad to hear that the workaround works for you!
|
|
Rank: Member Groups: Member
Joined: 5/6/2015 Posts: 25
|
Could the new "Added WebView.IsCreated property" help ? .. Or shows it only that the base class webview is ready ?
|
|
Rank: Member Groups: Member
Joined: 5/6/2015 Posts: 25
|
With the new version i got only timeouts... bad choice
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, Do you get time out on LoadHtml or Capture? Can you isolate the problem into a test project and send the test project to us? See here for more details on how to send the test project to us: http://www.essentialobjects.com/forum/test_project.aspxThanks!
|
|
Rank: Member Groups: Member
Joined: 5/6/2015 Posts: 25
|
Sorry, the problem doesn't want to be extracted. why? i don't know. Some colleague tries also with no success. With the new DLLs and now with threadrunner i get no timeouts. only wrong rendering if i get the picture to early.
Code: Visual Basic.NET
Cloc_WebView = Cloc_threadRunner.CreateWebView
Cloc_threadRunner.Send(Sub()
If Cloc_WebView.LoadHtml(trans_html).WaitOne(3000) = True Then
System.Threading.Thread.Sleep(50)
Using Loc_Image As Drawing.Image = Cloc_WebView.Capture(True)
Using Loc_Bitmap As New Bitmap(Loc_Image)
Using ms As New IO.MemoryStream()
Loc_Bitmap.MakeTransparent(Drawing.Color.White)
Loc_Bitmap.Save(ms, Drawing.Imaging.ImageFormat.Png)
ms.Position = 0
FU_GenerateBase64 = System.Convert.ToBase64String(ms.ToArray)
End Using
End Using
End Using
Else
Loc_TimeOut = True
End If
End Sub)
looks like the twice rendering that solved a litte bit from the older DLLs doesnt work. Replaced with Thread.Sleep and ThreadRunner it works. I hope the next release have a way to get rid of the sleeping.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
I see. Thank you very much for the update. We will investigate this and see what we can find.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/6/2015 Posts: 25
|
I've tested EO.Total 2015.2.1.2 looks nearly the same. I've reduced the thread.sleep to 25ms without geting wrong images.
|
|