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

Streaming Level 中的单位有时调用 Lua 实现时,self 是 userdata #380

Closed
xiejiangzhi opened this issue Mar 12, 2022 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@xiejiangzhi
Copy link
Contributor

xiejiangzhi commented Mar 12, 2022

版本是 2.1.3
之前 2.1.1 没这问题

升级到 2.1.3 后随机出现这个问题

比如 Streaming Level 加载的 actor 的 ReceiveTick 里面
有时会发现 type(self) 是 userdata ,是一个 ABP_xxx 对象,过几帧后, initialize 被调用后,才变回 table 对象。

我们不可能一直在 ReceiveBeginPlay 和 ReceiveTick 中加一个检查 type(self) == 'table' 吧?
我觉得,要么分开,要么就在调用前创建对应的 lua table 并 initialize

@xiejiangzhi
Copy link
Contributor Author

StreamingLevel 的actor ReceiveBegin 也会出现调用时是 userdata 而不是已经初始的 table

目前我就暂时 if type(self) ~= 'table' then return end

然后给 Initialize 加了一个是否已经初始化的参数,然后对于已经初始化的Actor 与 Component, 由 Lua Initialize 主动来调用 ReceiveBeginPlay 了。

            AActor* Actor = Cast<AActor>((UObject*)(Object));
            bool bBegunPlay = false;
            if (Actor) {
                bBegunPlay = Actor->HasActorBegunPlay();
            } else {
                UActorComponent* Comp = Cast<UActorComponent>((UObject*)(Object));
                bBegunPlay = Comp && Comp->HasBegunPlay();
            }
            lua_pushboolean(L, bBegunPlay);
            bResult = ::CallFunction(L, 3, 0);                                 // call 'Initialize'

虽然比较绕,但问题暂时是解决 userdata 调用与BeginPlay 的初始化问题了。把 userdata 作为 self 调用 lua 的功能还是改掉比较好,或者考虑调用带后缀的 ·ReceiveBeginPlayRaw· 不确定可行性如何。

@xuyanghuang-tencent
Copy link
Collaborator

#379 可能同一个问题,家里测试环境不全,麻烦帮忙验证一下上面这个修正?

@xiejiangzhi
Copy link
Contributor Author

感谢修复,基于你的新修改,测试了十来次没有出现 self 是 userdata 的情况了。
之前是每两三次就会出现一次。新创建的 level 放点 actor 进去,动态加载,又重现不了,不知道是不是数据过少。

@xuyanghuang-tencent xuyanghuang-tencent added bug Something isn't working pending release This will be released on next version labels Mar 21, 2022
@xuyanghuang-tencent
Copy link
Collaborator

v2.1.4

@xuyanghuang-tencent xuyanghuang-tencent removed the pending release This will be released on next version label Nov 7, 2023
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