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] Bug: await $promise还未执行完停止了编辑器。时间到的时候控制台报错JsEnv has been disposed #1975

Open
3 tasks done
wardehuang opened this issue Jan 25, 2025 · 2 comments
Assignees
Labels
bug Something isn't working Unity

Comments

@wardehuang
Copy link

前置阅读 | Pre-reading

Puer的版本 | Puer Version

2.1.1、2.1.2

Unity的版本 | Unity Version

2022.3.55f1

发生在哪个平台 | Platform

Editor(win)

错误信息 | Error Message

Exception: JsEnv has been disposed, stacktrace: at puerts\csharp.mjs:126:27
at taskToPromise(puerts\csharp.mjs:125:12)
at asyncCall(Quickstart.mjs:89:17)

问题重现 | Bug reproduce

  1. 下载官方的demo
  2. 替换zip包中05_Typescript的文件。SomeClasses.cs、Resources\QuickStart.mjs
  3. 打开代码查看SomeClasses.cs,增加如下函数

Image

  1. 打开代码查看QuickStart.mjs,增加如下逻辑

Image

  1. 直接不作改动运行,并在出现[file length is]日志后,3秒内停止运行,控制台报错

Image

05_Typescript.zip

@wardehuang wardehuang added bug Something isn't working Unity labels Jan 25, 2025
@chexiongsheng
Copy link
Collaborator

这符合预期。
虚拟机停止本来就是大事情,C#、java、nodejs上的v8等虚拟机是程序退出才停止的。
如果你想运行中停止虚拟机,应自己保证停止虚拟机前不再持有该虚拟机的任何资源。async实际上是外部还引用着js的一个闭包。
业务没有做到底层仅仅抛个异常是相当友好了。

@wardehuang
Copy link
Author

好的,谢谢

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

No branches or pull requests

2 participants