View Full Version : RunTime Functions in AVS+


GillesH
8th June 2019, 09:08
Problem with RunTime functions in AVS+.
I use in MT with Prefetch(4).
If I use ScriptClip or FrameEvaluate or a function like "filldrops" by John Meyer, I have a message that appears:
"Plane Difference: This filter can only be used within run time filters" "([ScriptClip], line 1)"

If I delete Prefetch, the error message disappears.
These functions work well in AVS-MT

Thank you for your suggestions

StainlessS
8th June 2019, 10:12
Does adding Grunt to plugins make the problem go away ?

pinterf
8th June 2019, 10:14
You have run into an existing bug.

StainlessS
8th June 2019, 10:22
You have run into an existing bug.

This works OK in v2.60 standard with Grunt in Plugins [EDIT: shows current_frame=True]


Colorbars
Function Fn1(clip c) {
EX=VarExist("current_frame")
return c.Subtitle("current_Frame Exist = " + string(EX))
}

SSS="""Fn1"""

Last.Scriptclip(SSS)

return last


but not in avs+,

But if change Scriptclip to GScriptClip, then works also in AVS+

EDIT: Above without any of that Prefetch thingy stuff.

GillesH
8th June 2019, 13:47
I redid many tests.

With the script of StainlessS, I get the same result WITH and WITHOUT GRunT.
There is no longer the same error message mentioned in the previous post. Here is the result on the image:
https://forum.doom9.org/attachment.php?attachmentid=16865&stc=1&d=1559997625

On the other hand, if I use GRunT with FrameEvaluate or filldrops, there is a crash.
Without GRunt, no crash, but always the same error message with Prefetch enabled.
https://forum.doom9.org/attachment.php?attachmentid=16866&stc=1&d=1559997697

Please, just try John Meyer's "filldrops" to see this flaw.
https://forum.doom9.org/showpost.php?p=1775184&postcount=5

real.finder
8th June 2019, 13:48
You have run into an existing bug.

and it will never fixed?

don't know how things work in avs-mt/avs+ mt but if making all things in single Thread but when the filter is MT_MULTI_INSTANCE or MT_NICE_FILTER will work in wrapper (I think this what vs do), will fix the problem?

StainlessS
8th June 2019, 14:04
First and second links in post #5 bring up an page saying "Invalid Attachment specified. If you followed a valid link, please notify the administrator".

GillesH
8th June 2019, 14:39
The links work for me. I do not understand where is this problem "Invalid Attachment" ...
This being so, it is not too important. These are just pictures of the messages created by the RunTime problem.
Here is the text of the photos:

With the StainlessS script: "current_Frame Exist = false"
With the filldrops function: "Plane Difference: This filter can only be used within run-time filters / ([Conditional Filter, Expression 1], line 1)"

StainlessS
8th June 2019, 15:03
The links have not yet been approved, so only you can see them, and when approved, then your links are unnecessary as everyone can then see them without your additional links.

GillesH
8th June 2019, 16:49
If John Meyer goes through Doom9.
Did you try your "filldrops" function with Prefetch in your new script AVS+ ?

pinterf
8th June 2019, 17:39
and it will never fixed?

don't know how things work in avs-mt/avs+ mt but if making all things in single Thread but when the filter is MT_MULTI_INSTANCE or MT_NICE_FILTER will work in wrapper (I think this what vs do), will fix the problem?
Filters instantiated inside scriptclip should not appear in an other thread. If current_frame is set in one thread, an MT_MULTI_INSTANCE filter or function will not see it. The error message "... can only be used..." means that there is no "current_frame" variable is seen there. Same applies on "last" which is also a sensitive variable.

StainlessS
8th June 2019, 20:00
I knew that there must be a reason that I dont use multithreading, now I know why :)

pinterf
8th June 2019, 20:55
MT makes programmers' sleep uneasy, especially when it was coded by others but one still has to reverse engineer and fix things. I already spent weeks on this very topic, source is full with by debug lines - I'm not proud of it :), but it was a couple of years ago, at that time I even had difficulties with elementary school-level c++ stuff - and abandonded the search for the solution for some days which became "forever".
As I remember, fixing the thread visibility was not enough, there was another problem: deadlocking occured sooner or later and I couldn't solve that in the given free time.

johnmeyer
8th June 2019, 21:37
If John Meyer goes through Doom9.
Did you try your "filldrops" function with Prefetch in your new script AVS+ ?I posted a version of my film restoration script that is written for AVISynth+. I am using r2508 MT, i386, by Ben Rudiak-Gould.

Here is a link to that script:

https://forum.doom9.org/showthread.php?p=1861734#post1861734

I just ran this (with GamMac enabled) and enabled filldrops(). I set the filldrops comparison variable absurdly high so filldrops would be activated on almost every frame. I had threads=3. I let the script run for a few minutes and on 720x480 16 fps progressive standard 8mm film, I got 4.68 fps.

I then did the same test, but with threads=1. After a minute (to let any caching clear out), I measured the fps and was getting 1.73. So the MT was definitely doing something.

I then set threads=8 (equal to the number of cores on my computer). This caused the render to "start and stop," with long pauses with no screen refresh. It finally froze.

Threads = 6 also froze. Also, I got an error I had never seen before: "Something appears to be stuck while trying to stop (thread deadlock)." This is exactly how it felt while the script was running, so I was not surprised.

While keeping threads at 6 I commented out the filldrops() call. This time it kept running, but there were long pauses where it didn't seem to be doing anything, and I got only about 2.2 fps.

I dropped threads to 5 and, without any calls to filldrops(), VD and AVISynth+ seemed to now be very happy, and I got 6.65 fps, a 50% increase from threads=3. I ran the script for over two minutes, and it seemed to be perfectly stable.

Since threads=5 seemed to be some sort of threshold, I kept it at 5 and then re-enabled the filldrops() call to see if the extra instance of MVTools2 (which is what this causes, since I'm not re-using any of the MVTools2 vectors, unless it is cleverly doing that behind my back) would cause a problem.

Well, performance plummeted to about 2.5 fps, and the script eventually hung. The extra invocation of MVTools2 definitely caused a problem (BTW, I'm not sure what version of MVTools2 I'm using, but I'm sure it is not very recent).

As the last test, I went back to threads=3, which is where I started, but with filldrops() enabled and with the filldrops() parameter set to cause it to execute on almost every frame. I got about 4.64 fps, but no screen refresh in VD, which made me wonder whether anything was really happening. I let it crunch for two minutes, closed VD, and then looked at the video it created. Despite not having any screen refresh in VD, the video produced by the script looked just fine.

I hope this helps!

P.S. If you need to know DLL versions, remind me what tool I use to get that (AVSMeter?) and I'll post that info.

StainlessS
9th June 2019, 00:38
Recomendation (bit pissed, you may choose to ignore or whatever),
have several machines at your disposal,
run em' all single thread,
set em off'

go to sleep, when done, sorted, easy peasy. no nonsense about how I get my CPU to run full tilt, really dont matter,
you will spend more time trying to fill up you brand spanking new 64 core machine with something to do , than if you just let em' do their own thing.

Life it too short to spend your time, tilting at wilndmills,
go get some sleep, it will sooner or later complete without lots of anxiety on your part. (EDIT: and probably a better un-messed up version will be in your in-box).

GillesH
9th June 2019, 09:10
John,
I no longer have the version AVS+ r2508 (like you). But I tried with an older version r2455 and I still have the same error message.
For now, I'm using the latest r2772 and the latest version of MVtools2 (2.7.39).
But I'm interested in the versions you use to compare.

To minimize interference, I put ONLY "filldrops" in a mini-script and with a simple SD AVI.
Whatever the number of threads in Prefetch, I still have the error message.

This message disappears only when I delete Prefetch.

I do not doubt, for a moment, that pinterf will find the solution because these RunTime functions are important for Avisynth.
Thank you in advance.

GillesH
9th June 2019, 14:21
I just did a quick test with the new AVSNEO_x86 and the problem is gone. It works with Prefetch.
I discover this Avisynth ...

Of course, this is worth a lot of time to perform multiple tests on other plugins.
And, there are, perhaps, other problems with this AVSNEO...

I can not conclude for this simple test and I remain convinced that Pinterf will find the right formula for AVS+.
Probably the "new poll" of Groucho2004 will give me reason ...

StainlessS
9th June 2019, 15:59
And, there are, perhaps, other problems with this AVSNEO...

Yes, a number of problems with NEO, they dont take too long to find.
It needs quite a bit of development work done to it, before it could be properley usable.

pinterf
10th June 2019, 08:00
Latest mvtools2 is .41
I'm seeing how the problem was fixed in neo, but that source is way too different now for just cherry pick those commits. It won't be a simple merge.

GillesH
10th June 2019, 12:03
Thanks for the latest mvtools2 .41
Concerning the RunTime problem, it is already important to have identified the solution in NEO.
We do not doubt that you will find how to do it. All our encouragement !