Perspective Component Script Actions not working (Ignition 8.0.9)

Forgive me if this is something obvious, pretty new to Ignition, and google searches have turned up nothing on this. For whatever reason on the production instance of Ignition, Event Script Actions don’t appear to ever correctly function. Other Event actions work, for example if I add the refresh action, the page will refresh but the script will not execute. Nothing advanced involved here, initially trying to execute a named query from an onclick event of a button. For trouble shooting purposes I went as simple as possible and created a whole empty project, 1 view with a button and a Led Display, on click of button to increment the value of the LED display by 1. This also fails. Move to test server, perform same action and the Display increments correctly. Still have a demo instance installed on my local machine, try it there and also works. So issue appears isolated to the one instance on the production server.
Is there a setting on the server that is potentially stopping all Perspective scripting? Did I overlook something obvious??

Without a screenshot, I can only sort of guess at the setup, but it sounds like you have multiple Actions set to execute as part of a single Event. (So the next bit is relevant insofar as you specified adding a refresh Action)

While we allow for this, it’s incredibly fragile - especially if any of the Actions is a Script - and here’s why:

Each Action receives its own thread on the Gateway, and they all execute from a pool. This means that there is every possibility that your script might take long enough to execute that other Actions have completed before it, which means that a lot of context could be lost.

As an example, let’s say that I have a Navigation Action and a Script Action both tied to a single onClick Event. The Script Action is “first”, followed by the Navigation Action. My Script checks several values on the Page, does a quick Tag value check based on those values, then grabs some other values form the page and then updates my Database. The Navigation Action takes me to a different page.

What you will often see in this scenario is that the navigation occurs, but the script seems to have no effect, and that’s because the Navigation Action is happening simultaneously with the script, so the simple navigation call on the back-end occurs, at which point the original page we were still interacting with no longer exists. If you look in the logs immediately after a scenario like this you’ll most likely see something like “received event for missing view @C:1” or something similar. It’s informing you that your Page has an Action thread which was running but it has lost context.

Workaround:
Whenever possible, please use a Script Action and place ALL of your logic and actions in the script. From the scenario I provided, I would keep my original script and then use system.perspective.navigate() at the very end of the script to perform the same behavior as if I had queued multiple Actions.

Or, I could be completely wrong about the setup. If this is truly only happening on a production server, have you verified the DB has all of the correct data in place? If there were any issue executing your script, I would expect logging to be present in the Gateway logs.

2 Likes

Sorry wasnt sure what info you wanted.

In an effort to flush out what the issue was I created a whole new empty project to test the simplest script possible. To the point I can not get this to correctly function on this particular installation. The point about the refresh action was just to say that OTHER non-script actions work in the event, just not the script action.

The displayed setup works correctly for me in both the Designer and a running Perspective Session, in that every button press increments the value of the LED by 1.

You mentioned that this was working in your test environment, but not production; how are you transitioning the content between environments? Are you exporting the project? Are you restoring from a Gateway Backup? Are you copying/pasting Views from one Designer to another?

Here is the log file …

java.lang.NoSuchFieldError: EDGE_SCRIPT_BYPASS

at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:76)

at com.inductiveautomation.perspective.gateway.action.ScriptAction.runAction(ScriptAction.java:71)

at com.inductiveautomation.perspective.gateway.action.ActionDecorator.runAction(ActionDecorator.java:18)

at com.inductiveautomation.perspective.gateway.action.SecuredAction.runAction(SecuredAction.java:51)

at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.lambda$call$0(ActionCollection.java:263)

at com.inductiveautomation.perspective.gateway.api.LoggingContext.mdc(LoggingContext.java:54)

at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:252)

at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:221)

at com.inductiveautomation.perspective.gateway.threading.BlockingTaskQueue$TaskWrapper.run(BlockingTaskQueue.java:154)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

OH! Is this an Edge Gateway!?

In this case a just made a new project since it was 2 objects and one statement… took nothing.

Dont believe so…

Your Perspective module version is out of sync with your gateway version. You have an 8.0.10 or nightly version of the Perspective module on an 8.0.9 gateway.

That was my initial thought as well…I reinstalled the previous version however?? Can I not just use the module upgrade path to revert to an older build?

I don't know what you mean by 'module upgrade path', but the version mismatch is 100% the cause. What is the listed version of the Perspective module on the Configure -> Modules page?

You may just need to restart the gateway to ensure you have the latest version of the module's files loaded; there were actually some changes in the code recently to better ensure Perspective 'cleans up' after itself when uninstalled on a live gateway.

1 Like

Ok if thats the cause I will get everything rolled back to the stable version and try again…

Was trying to play with 8.0.10s reporting control without having to download the full installation of 8.010 because now that everyone is work from home the VPN is crying :-).

Thanks for the help!!

You shouldn’t have been able to install the Perspective module from 8.0.10 into 8.0.9 without an error in the UI preventing you from doing it. That it was possible looks to be a bug with the Perspective module we shipped for 8.0.10.

Well I can tell you it was possible… I can also tell you the reporting control didnt appear anyway :smile: