Having system.perspective.print() in the .onShutdown event script of a view works and generates no errors in the browser session, but generates an error dialog when the view is closed in the designer (at least in version 8.1.37 and .42).
I tested in a "empty" project with a view that I opened as a popup with only a close button and only
system.perspective.print("onShutdown")
in the ,onShutdown event script. In the browser the string appears in the console when the view is closed, and no error appears in the logger. But when the view is closed in the designer, an error dialog pops up. The content varies, but in the empty test project and view it is (in part)...
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
File "<function:runAction>", line 2, in runAction
at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.lambda$operateOnPage$0(AbstractScriptingFunctions.java:79)
at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:120)
at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnPage(AbstractScriptingFunctions.java:47)
at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.print(PerspectiveScriptingFunctions.java:704)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.IllegalStateException: java.lang.IllegalStateException: Page is not running.
--- There is a bunch more but I think this is a bug that can be easily reproduced ---
Ignition v8.1.42 (b2024061810)
Java: Azul Systems, Inc. 17.0.11