Ranorex slow after moving to VS2010 / .NET4

Ranorex Spy, Recorder, and Studio.
TomF
Posts: 5
Joined: Mon Oct 18, 2010 3:06 pm

Ranorex slow after moving to VS2010 / .NET4

Post by TomF » Wed Dec 21, 2011 11:30 am

LS,

we are using Ranorex (version 2.3) to test our application. We want to move over to VS2010 / NET4 (we are using VS2008 / NET3.5). However while testing we found that version 2.3 is not supporting NET4.
So we migrated to Ranorex 3.2 and recompiled our scripts (downloaded the evaluation version).

This is what we found:
- The scripts do run but the test fail on time-outs (part of our scripts)
- We see high CPU loaded (UI thread is running at 100% for 10 seconds).

Configuration:
- Windows 7 embedded 64-bit (application 32-bit)
- GUI WPF and Windows forms
- Our application host process is build against .NET 3.5 we force the EXE to load the CLR 4.0 by means of the app.config file (not sure if this is relevant).

<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
</configuration>

This problem is currently blokking our migration so any help is welcome.

Update 21/12/2011
I did some debugging and what I found is that there lot of call to (340 calls)

Ranorex.Libs.WinForms.AssemblyResolver.AssemblyResolveHandler(System.Object, System.ResolveEventArgs)

I tried the same test on another system which is still using Ranorex version 2.3 and CLR2.x / NET 3.5.
To be a 100% sure I need to dig deeper but is the behaviour new to Ranorex 3.2 or is it new to CLR4?
Does this give a hint to solve this problem?

Here is part of the calls stack

Code: Select all

OS Thread Id: 0x1f08 (17)
Child SP IP       Call Site
0a54be30 5c075e00 Ranorex.Libs.WinForms.AssemblyResolver.AssemblyResolveHandler(System.Object, System.ResolveEventArgs)
0a54be34 68db0de1 System.AppDomain.OnAssemblyResolveEvent(System.Reflection.RuntimeAssembly, System.String)
0a54c074 6a2121db [GCFrame: 0a54c074] 
0a54d0ac 6a2121db [HelperMethodFrame_PROTECTOBJ: 0a54d0ac] System.Reflection.RuntimeAssembly._nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, Boolean, Boolean, Boolean)
0a54d154 68dce713 System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(System.String, System.Globalization.CultureInfo, System.Version, Boolean, System.Threading.StackCrawlMark ByRef)
0a54d17c 68dce4ea System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(System.Globalization.CultureInfo, System.Threading.StackCrawlMark ByRef)
0a54d1c0 68dbd314 System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(System.Globalization.CultureInfo, System.Collections.Generic.Dictionary`2<System.String,System.Resources.ResourceSet>, Boolean, Boolean, System.Threading.StackCrawlMark ByRef)
0a54d230 68dbcf95 System.Resources.ResourceManager.InternalGetResourceSet(System.Globalization.CultureInfo, Boolean, Boolean, System.Threading.StackCrawlMark ByRef)
0a54d298 68dbcd51 System.Resources.ResourceManager.InternalGetResourceSet(System.Globalization.CultureInfo, Boolean, Boolean)
0a54d2b4 68dd324a System.Resources.ResourceManager.GetResourceSet(System.Globalization.CultureInfo, Boolean, Boolean)
.....
Regards
TomF
Last edited by TomF on Wed Dec 21, 2011 3:37 pm, edited 1 time in total.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex slow after moving to VS2010 / .NET4

Post by Support Team » Wed Dec 21, 2011 11:52 am

Hi,

Please post (or send to [email protected]) the report file of the test case which fails.

Best Regards,
Martin
Ranorex Support Team
.
Image

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex slow after moving to VS2010 / .NET4

Post by Support Team » Wed Dec 21, 2011 2:39 pm

Hi,

Please read the information on working with 2.x projects in 3.x test suites.

Also read Reason #6 on General Troubleshooting.

Best Regards,
Martin
Ranorex Support Team
.
Image

TomF
Posts: 5
Joined: Mon Oct 18, 2010 3:06 pm

Re: Ranorex slow after moving to VS2010 / .NET4

Post by TomF » Wed Dec 21, 2011 3:49 pm

Hi, thanks for the fast response. I will check-out the tips you have given.
I have done a fast debug session and updated the initial post. Can you have a look.

Regards,
Tom

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex slow after moving to VS2010 / .NET4

Post by Support Team » Thu Dec 22, 2011 11:23 am

Hi,

did you do the Reason #6?

You have to use the same .NET version for your application and the testcase.

Regards,
Martin
Ranorex Support Team
.
Image

TomF
Posts: 5
Joined: Mon Oct 18, 2010 3:06 pm

Re: Ranorex slow after moving to VS2010 / .NET4

Post by TomF » Thu Dec 22, 2011 2:36 pm

Hi Martin,

I double checked but both the executables have an app.config file which contains a startup section to forward the EXE to CLR4.0 (like example 6).

Sorry. We need to define a debugging strategy so figure out the root cause.
What do you advice?

Regards,
Tom

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex slow after moving to VS2010 / .NET4

Post by Support Team » Thu Dec 22, 2011 3:18 pm

TomF wrote:hat do you advice?
Can you send us a (small) sample application that we can reproduce the problem with?
TomF wrote:We see high CPU loaded (UI thread is running at 100% for 10 seconds).
The CPU usage inside your AUT goes up to 100%? When does this happen (e.g. while recording/tracking/anytime)?
TomF wrote:I did some debugging and what I found is that there lot of call to (340 calls)
Well, 340 calls are not that many and the number of calls depends on the number of DLLs in your AUT. What's the total time those ~340 calls take?

Do you experience this behavior only on a single machine and with a single application or can you reproduce it on other machines/applications, too?

Regards,
Alex
Ranorex Team
.
Image

TomF
Posts: 5
Joined: Mon Oct 18, 2010 3:06 pm

Re: Ranorex slow after moving to VS2010 / .NET4

Post by TomF » Fri Dec 23, 2011 9:22 am

Hi,

we done some more debugging and this is what we found.

Microsoft indicates that there is a change in the ResolveEventHandlerEvent code:
http://msdn.microsoft.com/en-us/library ... .100).aspx
"Important
Beginning with the .NET Framework 4, the ResolveEventHandler event is raised for all assemblies,
including resource assemblies. In earlier versions, the event was not raised for resource assemblies.
If the operating system is localized, the handler might be called multiple times: once for each culture in the fallback chain."

We found that the method "GetResourceSet" is invoked by a framework we use in our software.
System.Resources.ResourceManager.GetResourceSet(System.Globalization.CultureInfo, Boolean, Boolean)

However the resource (tooltip) that is being retrieved cannot be found.
As a result the Ranorex.Libs.WinForms.AssemblyResolver.AssemblyResolveHandler gets invoked many times.
This lead to the delays. So we need to contact our supplier and fix the resource problem.

So the problem is not directly related to Ranorex. However it seems that the
Ranorex.Libs.WinForms.AssemblyResolver.AssemblyResolveHandler is slow which makes the problem visible. Something you might be able to change.

Regards,
Tom

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex slow after moving to VS2010 / .NET4

Post by Support Team » Fri Dec 23, 2011 11:32 am

TomF wrote:Microsoft indicates that there is a change in the ResolveEventHandlerEvent code:
Correct, we already considered that change in our code for .NET Framework resources. We could try to exclude all resources, but we are not sure if that would break existing code.

Could you provide us a sample application that causes the AssemblyResolve event to be fired for resources?
TomF wrote:However it seems that the Ranorex.Libs.WinForms.AssemblyResolver.AssemblyResolveHandler is slow which makes the problem visible. Something you might be able to change.
We can try to do something if you can provide us a sample application to reproduce the problem with.
Could you specify what "slow" means in e.g. milliseconds per call or total time for a number of calls?

Regards,
Alex
Ranorex Team
.
Image

TomF
Posts: 5
Joined: Mon Oct 18, 2010 3:06 pm

Re: Ranorex slow after moving to VS2010 / .NET4

Post by TomF » Thu Jan 05, 2012 6:53 am

Hi,

sorry for the delay (due to the holidays). I cannot provide sample code (it is a rather large code base). I made a patch to prove what I think is the problem. The patch seems to work (it reduces the number calls to fetch resources from the resource DLLs). Based on what I have seen I estimate that the overhead of Ranorex is a round 10 ms per call (our app slows down by approx. 3 seconds if Ranorex is active and the number of calls is around 300).

One of the reasons for the high number of calls is that when a resource cannot be found different cultures are tried e.g. en-US => en => No specific culture. Furthermore we have resources in multiple assemblies.

Regards,
TomF

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex slow after moving to VS2010 / .NET4

Post by Support Team » Mon Jan 16, 2012 10:57 am

We identified a possible issue in the AssemblyResolve event handler and will provide a fix in the upcoming Ranorex release 3.2.1.

Regards,
Alex
Ranorex Team
.
Image