AviSynth / AviSynthPlus

AviSynth with improvements
http://avs-plus.net
981 stars 76 forks source link

Ignore "invalid response to CACHE_GETCHILD_AUDIO_MODE" when they come from avs2.5 old plugins #365

Closed pinterf closed 1 year ago

pinterf commented 1 year ago

Probably since audio cache was reintroduced into Avisynth+ core*, error message appears when an older plugin compiled for Avisynth 2.5 interface (V3), e.g. dither tools is used.

As real.finder reported, anything newer than Avisynth+ 3.7.3 test 7 (20230223) will give same error.

https://forum.doom9.org/showthread.php?p=1989603#post1989603

Error message: "Cache: filter returned invalid response to CACHE_GETCHILD_AUDIO_MODE "

I remember there are already measures for other interface calls not to be done below V5, when they probably only return garbage. Let's try to do the same thing here as well.

FranceBB commented 1 year ago

+1 on this one, it shouldn't really fail with 2.5 plugins given that some of them have not been updated in years and a few of them might even be closed source, so it would fall under the core to play nicely with plugins targeting older interfaces.

FranceBB commented 1 year ago

Fixed by Ferenc as part of the final stable release of 3.7.3 with a conditional that checks the AVISYNTH_INTERFACE_VERSION and applies the appropriate workaround to make older filters work:

image

Thank you as always, Ferenc! ;)

realfinder commented 1 year ago

it still there using this dither.zip

LoadPlugin("dither.dll")
colorbars(pixel_type="yv12")
Dither_convert_8_to_16()
ditherpost(mode=-1)

image

FranceBB commented 1 year ago

Uhmmm interesting. That's 64bit I was testing on 32bit. With 64bit I'm on version v1.28.0 built on Wednesday 07 October 2020, 16.27.15

image

however even if I swap dither.dll 1.28.0 from October 2020 with the one you provided that was built on Monday 17 July 2023, 08.33.18, I get the same result:

image

VersionString: AviSynth+ 3.7.3 (r4003, 3.7, x86_64) VersionNumber: 2.60 File / Product version: 3.7.3.0 / 3.7.3.0 Interface Version: 10 Multi-threading support: Yes Avisynth.dll location: C:\WINDOWS\SYSTEM32\avisynth.dll Avisynth.dll time stamp: 2023-07-15, 21:48:08 (UTC) PluginDir2_5 (HKLM, x64): C:\Program Files (x86)\AviSynth+\plugins64 PluginDir+ (HKLM, x64): C:\Program Files (x86)\AviSynth+\plugins64+

[C 2.5 Plugins (64 Bit)] [Version, Time stamp] C:\Program Files (x86)\AviSynth+\plugins64+\assrender.dll [0.35.0.0, 2021-03-04] C:\Program Files (x86)\AviSynth+\plugins64+\mlrt_ncnn.dll [1.0.1.0, 2023-03-20] C:\Program Files (x86)\AviSynth+\plugins64+\mlrt_ov.dll [1.0.0.0, 2023-03-20]

[C++ 2.5 Plugins (64 Bit)] [Version, Time stamp] C:\Program Files (x86)\AviSynth+\plugins64+\dither.dll [n/a, 2023-07-17] C:\Program Files (x86)\AviSynth+\plugins64+\HDRMatrix-x64.dll [n/a, 2018-01-09] C:\Program Files (x86)\AviSynth+\plugins64+\HDRNoise-x64.dll [n/a, 2018-01-09] C:\Program Files (x86)\AviSynth+\plugins64+\HDRSharp-x64.dll [n/a, 2018-01-09] C:\Program Files (x86)\AviSynth+\plugins64+\LeakKernelDeint.dll [1.5.4.0, 2010-03-14] C:\Program Files (x86)\AviSynth+\plugins64+\VSFilter.dll [3.0.0.306, 2014-12-07] C:\Program Files (x86)\AviSynth+\plugins64+\warpsharp.dll [n/a, 2011-06-14]

Play audio is of course enabled in AVSPmod mod.

pinterf commented 1 year ago

I was testing on 32 bit without success, then with the provided DLL I changed to 64 bit environment. But so far no luck with this dither.dll either. I've got an older 64 bit avspmod however, from 2021. I have to find a newer one.

realfinder commented 1 year ago

weird, anyway, there are other people got it https://forum.doom9.org/showthread.php?p=1990611#post1990611

also, http://web.archive.org/web/20140420183914/http://bengal.missouri.edu/~kes25c/yadifmod_v1.zip will case same problem

pinterf commented 1 year ago

I was not able reproduce it with this yadifmod, neither from an avspmod from 2021 or an up-to-date 2023 version, nor from avsmeter. Then I tried GradFun3(thr=1.0, thrc=1.0) script from the doom9 link: from avsmeter and from avspmod. No error. I turned back to the 3.7.3 release versions from my already slightly modded version: no error.

Once in ~100 runs I've got a freeze with 3.7.3 release (x86) with the plain dither script, from avsmeter. No other signs of misbehaviour. However, Avsmeter is showing is a quick memory growth. This is because of a memory leak, which comes from avs 2.5 plugins ('baked code'): they do not care about the extra VideoFrame.frame_property structure. Such frame property memory area is not free'd up at all when they destroy a VideoFrame internally. Debug builds were showing a warning (assert) on this problem.

(Regarding x64 plugins from the Avisynth 2.5 era: I consider it a pure luck if they work without memory issues)

Anyway, here is a test build (real test, no git commit behind it!), please evaluate it, thanks. https://drive.google.com/uc?export=download&id=1dRlJXcDhCDt0lT1VmpSq30zsIfounMEm

realfinder commented 1 year ago

still get the "CACHE_GETCHILD_AUDIO_MODE" problem with 3.7.3post_20231016_test1 with dither.dll above

image

maybe there is a difference in the environment (Windows) between you and me that makes the problem not appear in your side?

realfinder commented 1 year ago

Maybe it has something to do with old dot vs comma problem? https://forum.doom9.org/showthread.php?p=1865986#post1865986

pinterf commented 1 year ago

Nothing to do with separators. The error message ("Trying alternative RGB32 conversion") shows however that the conversion in AvsPMod fails, when the resulting clip is converted to RGB32 (in order to display it).

AvsPMod is calling Avisynth's "invoke" to do the correction but this results in the "CACHE_GETCHILD_AUDIO_MODE" error. I see no error in the process, so I'm clueless at the moment.

                args = [self.display_clip, self.matrix, self.interlaced]
                try:
                    self.display_clip = self.env.invoke("ConvertToRGB32", args)
                except:
                    err = str(self.env.get_error())
                    if err:
                        self.convert_to_rgb_error = err + '\nTrying alternative RGB32 conversion'

Could you check whether you get error message or crash when you run the script with avsmeter/avsmeter64?

pinterf commented 1 year ago

Test build 2, the new hope. https://drive.google.com/uc?export=download&id=1xHP6jaFDpAb4j4pXKoVe2L6rw2qEohs4

realfinder commented 1 year ago

still same, anyway I think I know now

with dither + mt.zip

ClearAutoloadDirs()
import("MtModes.avsi")
import("dither.avsi")
LoadPlugin("dither.dll")
colorbars(pixel_type="yv12")
Dither_convert_8_to_16()
ditherpost(mode=-1)

the problem gone if I remove import("MtModes.avsi") so it's avs 2.5 plugin and MT problem?

pinterf commented 1 year ago

Yeah, I put SetFilterMTMode("DitherPost",MT_NICE_FILTER) in the test script and voila, I don't know if this filter is really fully reentrant, anyway now I can catch the error message.

(Dither_convert_8_to_16 does not count, it is not a filter, just a script)

pinterf commented 1 year ago

O.K. got it. I'm gonna publish a test build later.

pinterf commented 1 year ago

Check this one https://drive.google.com/uc?export=download&id=1auyCcQRg1QJbSc6RL1Rq53ApJ7KTVzxN

realfinder commented 1 year ago

that seems work, thanks

kedaitinh12 commented 1 year ago

Hi @pinterf, i got crash when use this 32 bit plugin in avs+ http://avisynth.nl/index.php/Zoom

pinterf commented 1 year ago

Hi @pinterf, i got crash when use this 32 bit plugin in avs+ http://avisynth.nl/index.php/Zoom

Not related to the current issue at all, this plugin does not work even with 3.6.0 avisynth version. Since the source code is available, try recompile it, or ask someone to refresh this plugin.