Welcome Guest Search | Active Topics | Sign In | Register

EO.WebBrowser wait for printing Options
Daniel Guenter
Posted: Tuesday, June 30, 2015 4:06:07 PM
Rank: Newbie
Groups: Member

Joined: 6/30/2015
Posts: 8
Hi, We purchased the EO.WebBrowser expressly for the purpose of printing html from our .net WPF application. We have a couple of problems with it.

1) If you do not dereference the WebView from the WebControl both object are not able to be GC'd due to event handlers holding references between the two objects. It would be nice if this was done with weak events so that the cleanup would be more simple.

2) More importantly the Print(x,x,x) function returns immediately with no task object to wait on completion. We need to close the view and cleanup after the printing has occurred, we cannot leave and reuse the print view. If we close the view after the print method returns the print will not complete and simply blackholes. We have tried our cleanup in the BeforePrint event but this too is too early esp in regards to network printer that may take a while to respond. We need a deterministic way to depose of the browser after the printing is completed (sent to the spooler).

We have tried to gain a deeper understanding of these issues but the library is obfuscated and is making attempts at understanding the threading model difficult.

Any help on these issues would be great.

Daniel
eo_support
Posted: Tuesday, June 30, 2015 7:17:57 PM
Rank: Administration
Groups: Administration

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

Thank you very much for the feedback.

As to #1, I believe if you explicitly remove the WebControl from its container, it will practically isolate the WebControl/WebView pair from anything else. After this they will be eligible for GC because they are not reachable from anywhere else within your code. It doesn't matter whether they reference each other. What matters is whether they are reachable. .NET itself has a lot of circular references (for example, parent/child controls) and they can all be GCed fine as soon as you severe the link between them and others.

As to #2, I believe we will need some kind of AfterPrint event so that you can track whether the printing is still in progress along with BeforePrint event. These two events should be sufficient for you to track the printing progress since a WebView can only have at most one printing job at the same time. We will try to implement this and update again once it's implemented.

Thanks!
Daniel Guenter
Posted: Thursday, July 2, 2015 2:09:21 PM
Rank: Newbie
Groups: Member

Joined: 6/30/2015
Posts: 8
Thanks so much for your reply.

#1 Even after completely dereferencing the control and indeed closing the window does not cause the WebControl or the WebView to be garbage collected. I can submit a project that demonstrates my problem if you wish.

https://github.com/MemoryExpress/EOBrowserDispose

Please use your obfuscated code to reproduce these memory leaks, the process of obfuscation seem to be creating a lot of delegates which can leave object references around.

Also it seems that Dispose needs to be called on the webView as the finalizers do not seem release the unmanaged resources.

#2 That would be so great if you could provide an after print event. We could then close our print window and perform cleanup.

Thanks, Daniel
eo_support
Posted: Thursday, July 2, 2015 7:48:14 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Thanks for the test project. We will look into it and get back to you as soon as possible.
eo_support
Posted: Friday, July 3, 2015 3:46:02 PM
Rank: Administration
Groups: Administration

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

We have posted a new build that added AfterPrint event. This event will be fired as soon as all the pages have been sent to the printer. Note that this is not the same as printer finishes printing. The printer may take a while to actually finishes printing.

We have also looked into the GC issue. Using your test project, sometimes we can reproduce the issue, but sometimes we can not. If you move the code that checks whether the objects are still alive in a different function and calls it from a separate button, the issue will not occur. We have also used a memory profiler to examine the heap and we do not see either object. So we believe the objects are properly disposed, it's just a matter of timing when the GC actually occurs.

Thanks!
Daniel Guenter
Posted: Monday, July 6, 2015 4:06:55 PM
Rank: Newbie
Groups: Member

Joined: 6/30/2015
Posts: 8
This is great! The new after-print method seems to be working fine and we are able to release the memory. We are implementing this build now, thanks so much.

Daniel
eo_support
Posted: Tuesday, July 7, 2015 2:46:55 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Great. Glad to hear that it's working for you. 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.