WARNING : This site is outdated and the PopcornFX team will no longer answer your questions here.
For all support questions please go to our Discord server
0 like 0 dislike
230 views
We seem to have gotten some issues when we've upgraded the popcornfx unity plug-from 2.7.  to 2.8.

The editor version is still 1.9.4.

When re-baking the effects, they wouldn't merge correctly with files of the same name in Unity.

When an effect is destroyed it would crash unity.

Our programmer said something about the m_SamplersCache being null and that that's when the Unity crashes:

"void OnDestroy()
{
    this.KillEffect();
    this.StopEffect();
    for (int i = 0; i < m_FxSamplersList.Count; i++)
    {
             if (m_SamplersCache[i].m_Data != IntPtr.Zero &&
            m_SamplersCache[i].m_Type1 != (int)PKFxManager.ESamplerType.SamplerCurve)
            Marshal.FreeHGlobal(m_SamplersCache[i].m_Data);
       }
    if (this.m_AttributesGCH.IsAllocated)
        this.m_AttributesGCH.Free();
    if (this.m_SamplersGCH.IsAllocated)
        this.m_SamplersGCH.Free();
    if (this.m_SamplersCurvesDataGCH.IsAllocated)
        this.m_SamplersCurvesDataGCH.Free();
}

"

My solution:

I've been able to fix it by cloning the effect in PK Editor and renaming it. Since the files had to be the same name I would just  open the renamed effect with notepad and copy it's contents to the effect in Unity.
by Zheljka (720 points)

1 Answer

2 like 0 dislike

Hi Zheljka,
I actually caught and fixed that bug last week.
I also added several missing checks, so you can replace your OnDestroy method with the following :

    void OnDestroy()
    {
        this.KillEffect();
        this.StopEffect();
        for (int i = 0; i < m_FxSamplersList.Count; i++)
        {
            if (m_SamplersCache != null && m_SamplersCache[i].m_Data != IntPtr.Zero &&
                m_SamplersCache[i].m_Type1 != (int)PKFxManager.ESamplerType.SamplerCurve)
                Marshal.FreeHGlobal(m_SamplersCache[i].m_Data);
        }
        m_SamplersCache = null;
        if (this.m_AttributesGCH != null && this.m_AttributesGCH.IsAllocated)
            this.m_AttributesGCH.Free();
        if (this.m_SamplersGCH != null && this.m_SamplersGCH.IsAllocated)
            this.m_SamplersGCH.Free();
        if (this.m_SamplersCurvesDataGCH != null && this.m_SamplersCurvesDataGCH.IsAllocated)
            this.m_SamplersCurvesDataGCH.Free();
    }

Cheers,

image

by Raphael (10.6k points)
Hello Raphael,

Quick question : me and my team have been experiencing issues with Unity crashing and I was wondering if your fix would have affected this issue :
Apply the same effect to several prefabs.
Instance those prefabs.
Run the game.
Crash

Another scenario :
Bring in a fresh effect to Unity.
If the effect had Play On Start flag ticked it would occasionally crash Unity.

If your fix somehow fixes above issues, where would I get that fix?
Cheers,
I don't see how the fix could induce such behaviour.  
Can you look at the Unity logs (https://docs.unity3d.com/Manual/LogFiles.html) and report back with what you find?
Sorry, I must have not made myself clear. I was asking whether your fix could have possibly fixed the bug I have mentioned, not induce it.
I have a log a dmp. Should I send them your way ?
Oh my bad, I must have read your comment too fast.  
Yes, please send them our way to support@popcornfx.com
Thanks,
...