Copy link to clipboard
Copied
Hi
A user has reported that one of my plugins is crashing. His description is that when he uses the mouse to adjust any of my controls After Effects exits with absolutely no error message. However if the control is selected and the keyboard is used to set the control then the plugin renders correctly.
I am unable to reproduce any such problems on my machine so am struggling somewhat to fix this. He did state that the machine he is using is new and very high powered with multiple CPU cores and a high power graphics card, whereas my development machine is a lowly laptop with onboard graphics and a meagre core i3 processor. Both of us are using Windows.
I just wondered if anyone had seen any similar behaviour before? The plugin is a smart plugin. I am wondering if I have some problem with re-entrant behaviour. I do not checkout any layers other than the input layer, but I wondered if it is possible for multiple AE threads to call my plugin at the same time? My first step has been to send the user a plugin version which logs every function entry and exit and the command codes sent in, but unless there is something really obvious in there it is going to be a real struggle to fix this.
Phil
Copy link to clipboard
Copied
what version of AE is he using? because 13.5 introduced separate threads
for the render and UI, which may create both re-entrancy and a few other
problems related to multi threading...
anyways, you can send that user a custom build containing some debug code
that you can write to file. at least that way you can start with some
elimination.
Copy link to clipboard
Copied
I've just checked and he is using 2015 and I am using 2014. So this is likely the issue.
I have seen that the 2015 SDK is now available and I've had a quick browse of the docs, I couldn't see a definitive list of which thread sends which commands, but I am guessing my problems come from the user changed param command arriving part way through a render. The user has another of my plugins which doesn't watch any parameters and this works fine.
I have a couple of follow on questions:
What will happen if both threads try to lock and unlock my global data? Is there any reference counting associated with these calls? I am guessing that something like this is the likely cause of the crash.
Can I add a mutex to my entry function as a short term workaround until I can fix this properly or will this cause more problems in AE? I assume that such a mutex will simply result in performance similar to CC2014?
Phil
Copy link to clipboard
Copied
if i recall correctly, the global data handle is the same one for the
render and ui threads. locking it from both threads at the same time should
not present a problem.
what's happening in CC2015 is that there are actually two separate
projects. one for the UI to read and change, and one for the render TO READ
ONLY.
the render thread is not allowed to make any changes to the project, and
the render project is synchronized with the UI project rapidly.
i'm only theorizing here, but using a mutex can cause a deadlock, as the UI
thread may be waiting for the render thread to exit for it could
synchronize, while the render thread is waiting for the ui to finish...
Copy link to clipboard
Copied
Thanks Shachar
I guess that means there is some reference counting or something so that both threads need to release the global data before it is actually released. That is good to know.
The read only bit is useful to know. I had been using global data to pass information between different classes in my code to avoid using a global. I will have to rethink this method I guess and perhaps this is what is causing the crash.
Thanks also for the mutex information, I guess that means that certain callbacks can cause control to be relinquished in a way that involves them waiting for something from the other thread. Definitely something to watch out for then.
I will have to get CC2015 installed and see how things work out.
Copy link to clipboard
Copied
gloabal data is actually some "grey area" in terms of the render thread not
being allowed to change the project.
the global data is not really part of the project. the reasoning behind the
ban is that there are multiple render threads, that can run at any time
regardless of user interaction, so they can't have the project change from
under their feet. so the engineers at adobe decided on the "one way street"
from the ui project version to the render project version, and not the
other way around. that being said, not you can decide what changes you can
and perhaps even should do to the global data during a render.
just...
experiment.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now