Script Access, Post, Send, Execute, BUGs?

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Script Access, Post, Send, Execute, BUGs?

Post by PaulDaMacMan » Tue Nov 24, 2020 2:51 am

Here goes...
I have an LCB library that I'm working on (actually several) that sends a lot of "Post" messages back to the engine, sometimes rapidly.
What happens intermittently is that an LCB error gets thrown "Script Access Not Allowed" when there's a message "post" called that tries to set a property, which causes a "redraw all" re-rendering of a widget (my own Piano Widget), in or on the target ScriptObject.

It seems that rather than queuing the next posted message until the Widget is finished doing it's thing, the script engine tries to execute the command immediately, but the widget is busy and so it throws the error in the middle of redrawing the widget. I tried making the target script object both the Widget itself and "This Stack" that then sends-in-time a message to the widget (figuring that might queue the message in a more forgiving way), but no joy. If I set the "lock errors" and/or wrap handlers in try/catch in the target stack, it seems it still throws these error but does so silently, causing graphical tearing for a second (usually making a stuck on note/hilite), but then it continues on for a bit until it ultimately hard-crashes the engine. I tried several other approaches too, like a timer loop that handles issuing the render-causing property setting in intervals, with results of various working time before hard-crash.

Now this only happens when It's my library communicating with the widget or from post-to-stack-to-widget. The widget itself works just fine when it's a user interacting with it. In fact it renders the same type of redraws that I'm trying to automate at pretty much blazing speeds when its working as a user driven control (versus the sort of library-to-stack-to-widget scripted messaging system I'm trying to do).

So I then basically recreated the Piano widget as a regular stack/card using the regular Graphic objects and it works fine, just like I wanted it to. Now I feel like I wasted a month and a half working on that Piano Widget! I've tried to optimize the Widget a bit to minimize redraws, to no avail. This is a really show stopper. I'm convinced that this isn't the intended behavior, and this is a bug.

I've also tried the alternatives to the "Post" command, execute script "my script", and LCB's version of the "send" command. Neither of those helped any, in fact Post "Message" to mScriptObject with [pParam,pParamTwo,etc], is the only one of those forms that seems to work at all AFAIK ( although I do recall getting "execute script" to set a stack level global variable at one point)

When I get a chance I'll make a video so you all can see what I'm talking about and update this thread with a link.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: Script Access, Post, Send, Execute, BUGs?

Post by PaulDaMacMan » Tue Nov 24, 2020 6:31 pm

https://www.youtube.com/watch?v=psR1dJ0PiNA

At the end of the video you see me switch the MIDI IN Post messages target ScriptObject to my Piano Widget, and the whole thing crashes after rendering a handful of notes. The on-screen piano in the upper half of the screen "3OctavePiano" is the rebuilt as stack/card/graphic objects version which you can see works just fine.
The two other apps I'm using for simulating external MIDI device input, are the free open-source VMPK (Virtual MIDI Piano Keyboard) and MidiKeys from the App Store.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

Post Reply

Return to “LiveCode Builder”