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

[Unity]GenericDelegate析构检查到jsenv被dispose,无需抛异常 #1677

Closed
chexiongsheng opened this issue Mar 21, 2024 · 0 comments
Closed

Comments

@chexiongsheng
Copy link
Collaborator

detail | 详细描述

首先(新版)nunit要求在OneTimeTearDown方法中对JsEnv变量Dispose
https://github.com/Tencent/puerts/actions/runs/8358232240/job/22879060265

Error: /Users/runner/work/puerts/puerts/unity/test/Src/Cases/AccessControlTest.cs(39,23): error NUnit1032: The field DefaultDontBindingEnv should be Disposed in a method annotated with [OneTimeTearDownAttribute] 

加上后,会报如下错误:
https://github.com/Tencent/puerts/actions/runs/8368563099/job/22912863909

The active test run was aborted. Reason: Test host process crashed : Unhandled exception. System.InvalidOperationException: JsEnv has been disposed!
   at Puerts.JsEnv.CheckLiveness() in D:\a\puerts\puerts\unity\Assets\core\upm\Runtime\Src\Default\JsEnv.cs:line 829
   at Puerts.GenericDelegate.CheckLiveness(Boolean shouldThrow) in D:\a\puerts\puerts\unity\Assets\core\upm\Runtime\Src\Default\JSType\GenericDelegate.cs:line 362
   at Puerts.GenericDelegate.Finalize() in D:\a\puerts\puerts\unity\Assets\core\upm\Runtime\Src\Default\JSType\GenericDelegate.cs:line 369

Dispose前加上强制gc问题解决

public void Cleanup()
 {
          GC.Collect();
          GC.WaitForPendingFinalizers();
          DefaultDontBindingEnv.Dispose();
 }

不过感觉GenericDelegate的析构检查到jsenv被dispose,不必抛异常,由于gc的不可控GenericDelegate的释放可能比较后,属于正常现象。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant