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

[UE] Bug: 在setTimeout中清理自身后,嵌套的setInterval和setTimeout不会执行 #1631

Closed
3 tasks done
lzj10 opened this issue Jan 12, 2024 · 2 comments
Closed
3 tasks done
Assignees
Labels
bug Something isn't working Unreal

Comments

@lzj10
Copy link
Contributor

lzj10 commented Jan 12, 2024

前置阅读 | Pre-reading

Puer的版本 | Puer Version

master 6256231

UE的版本 | UE Version

5.2

发生在哪个平台 | Platform

All

错误信息 | Error Message

No response

问题重现 | Bug reproduce

类似这么写的代码,test interval nest,test timeout nest不会输出,虽然代码写的有点奇怪,但是再chrome中可以正常运行,因为在复杂嵌套的时候很难保证在嵌套中没有清理自身的handle

        let a = setTimeout(() => {
            clearTimeout(a);
            console.warn(`test timeout`);
            setInterval(() => {
                console.warn(`test interval nest`);
            }, 1000);
        }, 1000);
        let a = setTimeout(() => {
            clearTimeout(a);
            console.warn(`test timeout`);
            setTimeout(() => {
                console.warn(`test timeout nest`);
            }, 1000);
        }, 1000);

原因是在clearTimeout的回调中释放了DelegateHandleId,然后在callback中调用setTimeout或者setInterval重新申请,callback调用结束后又再次删除了重新申请的DelegateHandleId

image

在chrome中可以正常运行。所以感觉是不是可以在callback执行后,判断!Continue删除定时器的时候,判断一下执行Function前后的TimerInfos[DelegateHandleId].TickerHandle是否一致,判断id是否有被复用申请再删除

@lzj10 lzj10 added bug Something isn't working Unreal labels Jan 12, 2024
@lzj10
Copy link
Contributor Author

lzj10 commented Jan 12, 2024

如果判断一下执行Function前后的TimerInfos[DelegateHandleId].TickerHandle是否一致,判断id是否有被复用申请再删除可以的话我提个pr

@lzj10 lzj10 changed the title [UE] Bug: 在setTimeout中不规范清理自身后,嵌套的setInterval和setTimeout不会执行 [UE] Bug: 在setTimeout中清理自身后,嵌套的setInterval和setTimeout不会执行 Jan 12, 2024
@terst6
Copy link

terst6 commented Jan 14, 2024

感谢,正好游戏中遇到这个问题。
我还遇到代理句柄疯狂增长的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Unreal
Projects
None yet
Development

No branches or pull requests

3 participants