Giter Club home page Giter Club logo

Comments (4)

yongkangchen avatar yongkangchen commented on September 28, 2024

重现方法:

function main()
    local go = UnityEngine.GameObject()
    local tween = go:AddComponent(TweenPosition)
    coroutine.wrap(function()
        tween:Play()
    end)()
end

from slua.

yongkangchen avatar yongkangchen commented on September 28, 2024

临时解决方案一:

function main()
    local go = UnityEngine.GameObject()
    local tween = go:AddComponent(TweenPosition)
    coroutine.wrap(function()
        local ok, err = pcall(function()
            tween:Play()
        end)
        if not ok then
            UnityEngine.Debug.LogError(err)
        end
    end)()
end

临时解决方案二:
将SLua.LuaState.errorReport函数里的:Debug.LogError(LuaDLL.lua_tostring(L, -1));改为: LuaDLL.lua_tostring(L, -1);

临时解决方案三:
修改Lua_UITweener.cs里的Play方法, 去掉try catch:

[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
    static public int Play(IntPtr l) {
        //try {
            UITweener self=(UITweener)checkSelf(l);
            System.Boolean a1;
            checkType(l,2,out a1);
            self.Play(a1);
            return 0;
        /*}
        catch(Exception e) {
            LuaDLL.luaL_error(l, e.ToString());
            return 0;
        }*/
    }

以上三种修改方法都可以避免crash,推测应该和 #53 一样,堆栈被破坏了。

from slua.

yongkangchen avatar yongkangchen commented on September 28, 2024

进一步分析:
checkType(l,2,out a1);这句是在c#里的try catch里执行的,而checkType导致lua抛出异常,调用lua_error到LUAI_THROW的_longjmp,然后跳到SLua.LuaState.errorReport。

猜测:在这种情况下,Debug.LogError尝试去获取堆栈信息导致crash, 因为lua虚拟机里的异常和mono里的异常发生冲突了

from slua.

yongkangchen avatar yongkangchen commented on September 28, 2024

所以我觉得要遵循一个原则,去避免这个问题:lua里的所有异常都在lua里处理,c#里的所有异常都在c#里处理,2者不能穿插。

from slua.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.