LabVIEW Project Providers

Reply
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.
Highlighted

"Global_Init" and "Provider_Startup" get called multiple times while loading

It appears that "Global_Init" and "Provider_Startup" get called multiple times while loading (they each get called the same number of times). I've not tried to fully characterize how many times these are called, but anecdotally, it appears related to the number of items in the project (more items == more calls to these functions). And just to quantify "called multiple times", that's between 1 and 6 calls.

This is not vital, just curious to know: what events trigger these callbacks?

Thanks!

0 Kudos
Message 1 of 8
(481 Views)
7 REPLIES 7

Re: "Global_Init" and "Provider_Startup" get called multiple times while loading

Hi Jack,


Not too sure about this.  I did some basic tests and it seems regardless of how many items in the project, both the Global Init and Provider Startup VIs were called only once at LabVIEW startup and once at project launch.  What did you do to see multiple calls?

My test:  LabVIEW 2011 and LabVIEW 2012 using the Secondary Provider Example. I placed a one button dialog in both "SecondaryProviderExample_Global_Init.vi" and "SecondaryProviderExample_Provider_Startup.vi".  I had to create the Provider Startup VI and alter SecondaryProviderExample_Provider_Interface.vi to account for the new file.


When loading LabVIEW, both VI's run once each, when creating a new project both VIs run once and when loading any existing projects both run once.

I might be able to get a better more concrete answer, but the developer who knows the details on this is out of the office.  I'll check with her once she returns and try to get some more info.

David

0 Kudos
Message 2 of 8
(423 Views)

Re: "Global_Init" and "Provider_Startup" get called multiple times while loading

Thanks for looking into this! Again, we can treat this as low priority, at this point it's still just a curiosity.

Inside both of my "Global_Init" and "Provider_Startup" callbacks (and every single callback), I have a little logger VI that does the quick and dirty job of execution tracing the last 32 project provider callbacks:

Screen Shot 2012-09-04 at 10.02.50 AM.png

That gives the following results:

Screen Shot 2012-09-04 at 10.02.05 AM.png

Also, interestingly, three shutdown almost immediately after launching at the time 9:30:14AM. Could these multiple calls be related to the number of lvclasses in the lvproj?

0 Kudos
Message 3 of 8
(423 Views)

Re: "Global_Init" and "Provider_Startup" get called multiple times while loading

This is true, the Global Init gets called a lot, I've not understood that as well.

I also think it get called when you add items in the project tree.

Jack, be careful in your provider code, if you add an item (e.g. a class like I do a lot) in the project tree, LV will call some init VIs from your code. That means your provider code (that added the item is still running), and at the same time another VI will be called by LV, this easily crashes LabVIEW.

I had to solve this, by adding a 150ms delay in my code always when I add an item to the project tree (i.e. causing LV to run a Provider.Init VI), basically wait before continuing my code so all INIT VIs have finished executing before I continue.

I looks like the application instance that is used for the provider VIs don't handle multitasking so good.

Message 4 of 8
(423 Views)

Re: "Global_Init" and "Provider_Startup" get called multiple times while loading

Certainly useful information, thanks Mikael! I have found 3 ways to crash LV so far, but they have all been due to errors I made; but will certainly look out for this one you mention.

0 Kudos
Message 5 of 8
(423 Views)

Re: "Global_Init" and "Provider_Startup" get called multiple times while loading

It is strange that I cannot get my code to trigger Global_Init more than once but I do know I've seen this behavior in the past.  I'll talk with Sumedha to try to find out what may cause it, but it might be a much deeper investigation into the LabVIEW source code to find out anything useful..

In the meantime, I would suggest assuming that the VIs will be called an indeterminable amount of times, and add code that accounts for it, such as using "first call" or the info you have stored in your shift register already.

Mikael, you are correct that the Project Provider application instance does have many unknowns to it and sometimes shows strange behavior.  This is why this feature never was truly opened up externally until recently and why we only open it to a limited (and exceptionally brilliant) audience.  Of course our goal is to fix any of these problems moving forward.  If you discover any obvious problems with providers, please don't hesitate to bring them to our attention so we can CAR and (hopefully) fix them.  This includes crashes, unexpected behavior or even subtle things such as poor documentation or missing functionality.

David

Message 6 of 8
(423 Views)

Re: "Global_Init" and "Provider_Startup" get called multiple times while loading

Hi Jack,

I don't have a solution to your "problem" but when we debugged the App Builder Support, we also created a LV2 global much like yours. The difference was that we also used the ObjectID to get the project item that was causing the Provider method to run.

/Jonas

Message 7 of 8
(423 Views)

Re: "Global_Init" and "Provider_Startup" get called multiple times while loading

Mellroth wrote:

Hi Jack,

I don't have a solution to your "problem" but when we debugged the App Builder Support, we also created a LV2 global much like yours. The difference was that we also used the ObjectID to get the project item that was causing the Provider method to run.

/Jonas

Clever! A little refactoring of the execution trace logger gives this:

Screen Shot 2012-09-06 at 10.34.43 AM.png  Screen Shot 2012-09-06 at 10.33.54 AM.png

I'm scratching my head as to why Provider-Shutdown events (log items 015-017) do not have an Item ID that corresponds to any of the Provider-Startup events (log items 001, 003, 005...), but these are questions that I will not investigate right now - perhaps later, if application functionality dictates.

0 Kudos
Message 8 of 8
(423 Views)
Reply
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.