Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有偶现的 无法调用到 oc类的情况 #8

Closed
ChenMengqi opened this issue Aug 18, 2020 · 2 comments
Closed

有偶现的 无法调用到 oc类的情况 #8

ChenMengqi opened this issue Aug 18, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@ChenMengqi
Copy link
Collaborator

可以确认的是 oc本身是可以调用到的, 不为空,但lua调用存在 偶现找不到方法的情况,原因未知,排查中。

报错信息为:
[SPA] PANIC: unprotected error in call to Lua API ([string "spa_class("xxxx")..."]:8: attempt to index a nil value)

@ChenMengqi
Copy link
Collaborator Author

此时 lua中获取到的self 为空

初步排查后,原因在 前后两次 类的实例 地址相同,导致

+ (int)createInstanceUserData:(lua_State *)L object:(id)object {
       ......
        lua_pushlightuserdata(L, (__bridge void *)(object));
       if(lua_isnil(L, -1) ){
       } else {
     }

走到了else逻辑,最后导致self为空

@hzfanfei
Copy link
Owner

lua_isnil(L, -1) 只判断空是不够的的,还要判断内部的instance是否为空

@ChenMengqi ChenMengqi added the bug Something isn't working label Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants