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

v8 reinit cause crash #2751

Open
neufeng opened this issue Sep 2, 2020 · 11 comments
Open

v8 reinit cause crash #2751

neufeng opened this issue Sep 2, 2020 · 11 comments
Assignees

Comments

@neufeng
Copy link

neufeng commented Sep 2, 2020

Cocos Creator 2.4.2
ScriptEngine::init()
_isolate = v8::Isolate::New(_createParams);

after exit cocos, then enter cocos again, crash on above line。It seams some incorrect use of Allocator!!!

@sky068
Copy link

sky068 commented Sep 16, 2020

我也遇到这个问题了,原生app集成cocos,二次启动就这个错误,请问有解嘛?

@PatriceJiang
Copy link
Contributor

v8::platform::NewDefaultPlatform().release();
v8::V8::InitializePlatform(_platform);


v8::V8::Dispose();
v8::V8::ShutdownPlatform();

不需要多次执行, 从 scriptEngine 中抽出来

@ljs19850321
Copy link

楼上正解,但是重新初始化有黑屏现象,你们有嘛? @PatriceJiang

@yuhanle
Copy link

yuhanle commented Apr 20, 2021

我们目前退出时没做释放,第二次进入直接获取之前的 v8 使用。没有遇到黑屏问题

@296230428
Copy link

楼上能给个 demo 看看吗

@wdx700
Copy link

wdx700 commented Aug 27, 2021

不释放V8,会导致V8一直在后台运行,占用内存和线程资源
如果不是纯游戏的APP,应该释放V8
目前也遇到这个问题,还没找到解决办法

@yuhanle
Copy link

yuhanle commented Aug 30, 2021

楼上能给个 demo 看看吗

不好意思,最近才看到这里的消息。我截了屏可以参考下 cc @wdx700

除此之外,v8 占用的内存不多

其中两个个文件的修改,按截屏顺序看

  1. cocos/bindings/jswrapper/v8/ScriptEngine.cpp
  2. cocos/bindings/jswrapper/v8/ScriptEngine.h

image

@wdx700
Copy link

wdx700 commented Aug 30, 2021

楼上能给个 demo 看看吗

不好意思,最近才看到这里的消息。我截了屏可以参考下 cc @wdx700

除此之外,v8 占用的内存不多

其中两个个文件的修改,按截屏顺序看

  1. cocos/bindings/jswrapper/v8/ScriptEngine.cpp
  2. cocos/bindings/jswrapper/v8/ScriptEngine.h

image

我们是自己改了Cocos的代码,封装成View方式加载cocos动画,退出页面时改cocos代码释放掉v8 engine
然后再次进入,第二次Initialize v8 engine,之后就会遇到崩溃
art_sigsegv_fault 0x0000007c07a7c2e8
art::FaultManager::HandleFault(int, siginfo*, void*) 0x0000007c07a7c7fc
art::SignalChain::Handler(int, siginfo*, void*) 0x0000005619525e54
0x0000007e9e6668b0
v8::internal::wasm::WasmEngine::AddIsolate(v8::internal::Isolate*) 0x0000007b97ddc608
v8::internal::wasm::WasmEngine::AddIsolate(v8::internal::Isolate*) 0x0000007b97ddc608
v8::internal::Isolate::Init(v8::internal::ReadOnlyDeserializer*, v8::internal::StartupDeserializer*) 0x0000007b97b25b80
v8::internal::Isolate::InitWithSnapshot(v8::internal::ReadOnlyDeserializer*, v8::internal::StartupDeserializer*) 0x0000007b97b260b0
v8::internal::Snapshot::Initialize(v8::internal::Isolate*) 0x0000007b97dc07b4
v8::Isolate::Initialize(v8::Isolate*, v8::Isolate::CreateParams const&) 0x0000007b97aa1270
v8::Isolate::New(v8::Isolate::CreateParams const&) 0x0000007b97aa1370
se::ScriptEngine::init() ScriptEngine.cpp:412
se::ScriptEngine::start() ScriptEngine.cpp:588
Game::init() Game.cpp:59
(anonymous namespace)::createGame(ANativeWindow*) JniCocosActivity.cpp:57
(anonymous namespace)::preExecCmd(signed char) JniCocosActivity.cpp:87
(anonymous namespace)::glThreadEntry() JniCocosActivity.cpp:134
decltype(std::__ndk1::forward<void ()()>(fp)()) std::__ndk1::__invoke<void ()()>(void (&&)()) type_traits:4353
void std::__ndk1::__thread_execute<std::__ndk1::unique_ptr<std::__ndk1::__thread_struct, std::__ndk1::default_deletestd::__ndk1::__thread_struct >, void (
)()>(std::__ndk1::tuple<std::__ndk1::unique_ptr<std::__ndk1::__thread_struct, std::__ndk1::default_deletestd::__ndk1::__thread_struct >, void ()()>&, std::__ndk1::__tuple_indices<>) thread:342
void
std::__ndk1::__thread_proxy<std::__ndk1::tuple<std::__ndk1::unique_ptr<std::__ndk1::__thread_struct, std::__ndk1::default_deletestd::__ndk1::__thread_struct >, void ()()> >(void) thread:352
__pthread_start(void*) 0x0000007e997b4d50
__start_thread 0x0000007e9975528c

@yuhanle
Copy link

yuhanle commented Sep 6, 2021

重复初始化是会有问题的,所以不建议重复初始化。可参考上面的截图,改造支持下 @wdx700

@zeinx920
Copy link

重复初始化是会有问题的,所以不建议重复初始化。可参考上面的截图,改造支持下 @wdx700

你好, 请问除了这里修改还需要改其他地方吗, 目前我们第二次进去还是会遇到黑屏的问题, 报错信息如下


2022-09-21 18:45:50.791 30276-30846/org.cocos2d.demo D/cocos2d-x: find in flash memory dirPath(/data/data/org.cocos2d.demo/files/temp)
2022-09-21 18:45:51.131 30276-30846/org.cocos2d.demo D/jswrapper: JS: Cocos Creator v2.4.9
2022-09-21 18:45:51.461 30276-30846/org.cocos2d.demo D/jswrapper: JS: InitScene: 4.0090000000000146ms
2022-09-21 18:45:51.461 30276-30846/org.cocos2d.demo D/jswrapper: JS: AttachPersist: 0.6080000000001746ms
2022-09-21 18:45:51.461 30276-30846/org.cocos2d.demo D/jswrapper: JS: AutoRelease: 0.875999999999749ms
2022-09-21 18:45:51.461 30276-30846/org.cocos2d.demo D/jswrapper: JS: Destroy: 0.06400000000030559ms
2022-09-21 18:45:51.811 30276-30846/org.cocos2d.demo D/jswrapper: JS: Activate: 343.56600000000026ms
2022-09-21 18:45:51.871 30276-30846/org.cocos2d.demo I/Adreno-ES20: <validate_vertex_attrib_state:61>: validate_vertex_attrib_state: No vertex attrib is enabled in a draw call!
2022-09-21 18:45:51.871 30276-30846/org.cocos2d.demo I/Adreno-ES20: <validate_vertex_attrib_state:61>: validate_vertex_attrib_state: No vertex attrib is enabled in a draw call!
2022-09-21 18:45:51.871 30276-30846/org.cocos2d.demo I/Adreno-ES20: <validate_vertex_attrib_state:61>: validate_vertex_attrib_state: No vertex attrib is enabled in a draw call!
2022-09-21 18:45:51.871 30276-30846/org.cocos2d.demo I/Adreno-ES20: <validate_vertex_attrib_state:61>: validate_vertex_attrib_state: No vertex attrib is enabled in a draw call!
2022-09-21 18:45:51.911 30276-30846/org.cocos2d.demo I/Adreno-ES20: <validate_vertex_attrib_state:61>: validate_vertex_attrib_state: No vertex attrib is enabled in a draw call!
2022-09-21 18:45:51.911 30276-30846/org.cocos2d.demo I/Adreno-ES20: <validate_vertex_attrib_state:61>: validate_vertex_attrib_state: No vertex attrib is enabled in a draw call!
2022-09-21 18:45:51.911 30276-30846/org.cocos2d.demo I/Adreno-ES20: <validate_vertex_attrib_state:61>: validate_vertex_attrib_state: No vertex attrib is enabled in a draw call!

@decwang
Copy link

decwang commented Nov 2, 2022

在退出时释放下DeviceGraphics这个单例对象就可以修复iOS的黑屏问题.Android目前我们用的是新进程的方式规避的.

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

9 participants