Title: Application hang when use DLL with Rtc Components Post by: ISIGest on October 27, 2016, 10:03:24 AM Hi, I've a big problem with an Application that use a DLL that contain a simple TRtcHttpClient and an TRtcClientModule used to call a function to remote server.
The Dll work fine but my application hang (for about 30s) when close. Title: Re: Application hang when use DLL with Rtc Components Post by: ISIGest on October 27, 2016, 10:43:42 AM I found some info into log:
2016-10-27 11:41:51.667; rtcWInetHttpCliProv Finalizing ... 2016-10-27 11:41:51.670; CloseThreadPool begin ... 2016-10-27 11:41:51.672; Threads Runnning: 2 2016-10-27 11:41:51.674; Post ThreadQuit 13716 2016-10-27 11:41:51.687; Post ThreadQuit 18776 2016-10-27 11:41:51.699; Waiting for all Threads to close ... 2016-10-27 11:42:22.905; Done waiting, 2 Threads (2+0) still busy! BUSY??? Title: Re: Application hang when use DLL with Rtc Components Post by: ISIGest on October 27, 2016, 10:49:50 AM If I try to CloseThreadPool manually I've this result into log:
Code: 2016-10-27 11:48:33.933; rtcWInetHttpCliProv Finalizing ... Title: Re: Application hang when use DLL with Rtc Components Post by: D.Tkalcec (RTC) on October 27, 2016, 11:41:08 AM How are TRtcHttpClient and TRtcClientModule components configured (properties)? I guess TRtcHttpClient component has MultiThreaded=TRUE, but how are the other properties set up on the TRtcHttpClient component (which define the API to be used) and does the TRtcClientModule have AutoSyncEvents=TRUE or FALSE? Are you closing the connection on all TRtcHttpClient components (using "DisconnectNow") before destroying Forms and/or DataModules used by the components?
Best Regards, Danijel Tkalcec Title: Re: Application hang when use DLL with Rtc Components Post by: D.Tkalcec (RTC) on October 27, 2016, 01:59:25 PM I've released the next RTC SDK update (v7.58). Using this update, if you manually call the "rtcShutDown" procedure before closing your Application, there should be no delays during your Application's finalization (at least none caused by RTC), but please note that using "rtcShutDown" will result in Memory Leaks and most likely cause Access Violations during shut-down.
A much better and cleaner approach would be to make sure that all RTC connections are closed (using DisconnectNow on the Client and StopListeNow on the Server) before destroying RTC components and any Forms and/or DataModules used by RTC components. If you are using the TRtcQuickJob component or directly posting jobs to the RTC Thread Pool by using the PostQuickJob procedure, you should also make sure that all jobs are finished before closing the Application (TRtcQuickJob component has properties to check the number of jobs left). Judging by the LOG entries you've posted above, something is preventing two RTC Worker Threads and at last one RTC Timer Thread from terminating, which means that two events triggered by RTC components are running in the background and either (A) waiting for something or (B) trying to access the Main Thread - while your Application is shutting down. If you are closing all RTC connections before terminating your Application (DisconnectNow / StopListenNow) and do NOT use any other RTC classes or components which might be using RTC Threads or Timers, then I will need more information about the way you are using RTC components. A list of properties on all RTC components would be a good start. Example Projects demonstrating the issue would be even better, so I can debug this locally to find out what is going on. Best Regards, Danijel Tkalcec Title: Re: Application hang when use DLL with Rtc Components Post by: ISIGest on October 28, 2016, 09:05:49 AM I've solved by unload the DLL before on each use.
Load -> Call -> Unload and skip the Detach on Application Close. Regards Title: Re: Application hang when use DLL with Rtc Components Post by: D.Tkalcec (RTC) on October 28, 2016, 09:49:41 AM I would have preffered to find the reason for RTC Worker and Timer Threads not terminating, but ... if you can not provide additional information and you are happy with your solution, I'm not going to argue.
Best Regards, Danijel Tkalcec Title: Re: Application hang when use DLL with Rtc Components Post by: HelgeLange on October 28, 2016, 09:36:29 PM I use a lot of DLLs and BPLs that are loaded dynamically and some of them use RTC, I have some problems to shut down sometimes. Not using worker threads there. Can't say, where it hangs, it's a small pìece of code some thing like WaitKillThread something, looks like windows internals, not my code for sure.
What could I use to know, if it's the fault of RTC ? I use RTC als runtime BPL. Helge Title: Re: Application hang when use DLL with Rtc Components Post by: D.Tkalcec (RTC) on October 29, 2016, 09:39:45 AM You can start by downloading the latest RTC SDK version and rebuilding any DLLs, EXEs and BPLs where you are using RTC components with a RTC_DEBUG compiler define declared. You can either delcare the RTC_DEBUG define in every Project or in the rtcDeploy.inc file (located in the RTC Lib folder).
If an Application "hangs" when closing and this "hanging" is caused by RTC SDK or by your code executed from inside RTC events, it will be visible in RTC log files (see LOG entries from ISIGest above for an example). Best Regards, Danijel Tkalcec |