■ Environment
Cocos Creator: 2.4.4 - 2.4.6
iOS: 12 - 15.1
Device: iPhone6, iPhone7, iPhone8, iPhoneX, iPhone11, iPhone12, iPhone13, iPad, etc
■ Overview
I receive a lot of crash reports every day on Crashlytics and App Store Connect.
Occurs when the app is closed from the task list 2-3 seconds after the app is started.
The recall rate by myself is about 10%.
■ Points
The point to be worried about is that it occurs when the remaining RAM is low in all crash reports. For example, 20MB-140MB.
Can the game engine fail to release when the memory capacity is low?
It all happens with cocos2d::Application::~Application().
■ Similar problems
Very likely to be the same as this problem. The demo is in this thread.
■ Log
Normal:
applicationWillTerminate
~AudioCache(id=1), delete buffer: 2425
ScriptEngine::cleanup begin …
GC begin …, (js->native map) size: 1994, all objects: 3811
GC end …, (js->native map) size: 1987, all objects: 3804
GC begin …, (js->native map) size: 1987, all objects: 3804
GC end …, (js->native map) size: 1987, all objects: 3804
GC begin …, (js->native map) size: 0, all objects: -1
Function object is released!
GC end …, (js->native map) size: 0, all objects: -1
ScriptEngine::cleanup end …
Failure:
applicationWillTerminate
~AudioCache(id=1), delete buffer: 2425
■ Crash pattern
There are two patterns of crash locations.
·pattern 1
cocos2d::AudioEngineImpl::~AudioEngineImpl()
EXC_BAD_ACCESS 0x0000000104f90109
·pattern 2
se::ScriptEngine::~ScriptEngine()
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000977
■ Stack trace
·pattern 1
0 libsystem_kernel.dylib 0x3908 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x2d0c mach_msg + 72
2 libEmbeddedSystemAUs.dylib 0x934a0 AURemoteIO::Stop()
3 libEmbeddedSystemAUs.dylib 0x27d8c AUMethodStop(void*)
4 AudioToolbox 0x1726e4 + 236
5 OpenAL 0x60ac OALDevice::DisconnectContext(OALContext*) + 180
6 OpenAL 0x2bcc OALContext::DisconnectMixerFromDevice() + 28
7 OpenAL 0x6a84 alcMakeContextCurrent + 304
8 appsname-mobile 0x458e58 cocos2d::AudioEngineImpl::~AudioEngineImpl() + 3240904
9 appsname-mobile 0x458fb8 cocos2d::AudioEngineImpl::~AudioEngineImpl() + 3241256
10 appsname-mobile 0x3e9b8c cocos2d::AudioEngine::end() + 2785532
11 appsname-mobile 0x3e6dbc cocos2d::Application::~Application() + 2773804
12 appsname-mobile 0xf360 AppDelegate::~AppDelegate() + 47 (AppDelegate.cpp:47)
13 appsname-mobile 0x1459c -[AppController applicationWillTerminate:] + 141 (AppController.mm:141)
·pattern 2
0 appsname-mobile 0x6ee644 void v8::internal::MarkingVisitorBase<v8::internal::MainMarkingVisitorv8::internal::MajorMarkingState, v8::internal::MajorMarkingState>::ProcessStrongHeapObjectv8::internal::FullHeapObjectSlot(v8::internal::HeapObject, v8::internal::FullHeapObjectSlot, v8::internal::HeapObject) + 249664
1 appsname-mobile 0x6ef81c int v8::internal::MainMarkingVisitorv8::internal::MajorMarkingState::VisitLeftTrimmableArrayv8::internal::FixedArray(v8::internal::Map, v8::internal::FixedArray) + 254232
2 appsname-mobile 0x6ef81c int v8::internal::MainMarkingVisitorv8::internal::MajorMarkingState::VisitLeftTrimmableArrayv8::internal::FixedArray(v8::internal::Map, v8::internal::FixedArray) + 254232
3 appsname-mobile 0x6d0230 unsigned long v8::internal::MarkCompactCollector::ProcessMarkingWorklist<(v8::internal::MarkCompactCollector::MarkingWorklistProcessingMode)0>(unsigned long) + 125740
4 appsname-mobile 0x6bcc70 v8::internal::MarkCompactCollector::MarkLiveObjects() + 46444
5 appsname-mobile 0x6bc6b4 v8::internal::MarkCompactCollector::CollectGarbage() + 44976
6 appsname-mobile 0x6a8570 v8::internal::Heap::MarkCompact() + 5172
7 appsname-mobile 0x6a5ed8 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) + 36120
8 appsname-mobile 0x6a41f0 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) + 28720
9 appsname-mobile 0x6a5310 v8::internal::Heap::PreciseCollectAllGarbage(int, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) + 33104
10 appsname-mobile 0x5c8a70 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) + 45056
11 appsname-mobile 0x5c7ff4 v8::internal::MaybeHandlev8::internal::Object v8::internal::(anonymous namespace)::HandleApiCallHelper(v8::internal::Isolate*, v8::internal::Handlev8::internal::HeapObject, v8::internal::Handlev8::internal::HeapObject, v8::internal::Handlev8::internal::FunctionTemplateInfo, v8::internal::Handlev8::internal::Object, v8::internal::BuiltinArguments) + 42372
12 appsname-mobile 0x5c78e0 v8::internal::Builtins::InvokeApiFunction(v8::internal::Isolate*, bool, v8::internal::Handlev8::internal::HeapObject, v8::internal::Handlev8::internal::Object, int, v8::internal::Handlev8::internal::Object, v8::internal::Handlev8::internal::HeapObject) + 40560
13 appsname-mobile 0x653798 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate, v8::internal::(anonymous namespace)::InvokeParams const&) + 199416
14 appsname-mobile 0x6532e4 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handlev8::internal::Object, v8::internal::Handlev8::internal::Object, int, v8::internal::Handlev8::internal::Object) + 198212
15 appsname-mobile 0x597860 v8::Object::CallAsFunction(v8::Localv8::Context, v8::Localv8::Value, int, v8::Localv8::Value) + 93032
16 appsname-mobile 0x4c8690 se::Object::call(std::__1::vector<se::Value, std::__1::allocatorse::Value > const&, se::Object*, se::Value*) + 3697664
17 appsname-mobile 0x44ca90 se::ScriptEngine::garbageCollect() + 3190784
18 appsname-mobile 0x14098 std::__1::__function::__func<jsb_register_all_modules()::$_1, std::__1::allocator<jsb_register_all_modules()::$_1>, void ()>::operator()() + 116 (jsb_module_register.cpp:116)
19 appsname-mobile 0x44ba00 se::ScriptEngine::cleanup() + 3186544
20 appsname-mobile 0x44b79c se::ScriptEngine::~ScriptEngine() + 3185932
21 appsname-mobile 0x44b410 se::ScriptEngine::destroyInstance() + 3185024
22 appsname-mobile 0x3e6dc4 cocos2d::Application::~Application() + 2773812
23 appsname-mobile 0xf360 AppDelegate::~AppDelegate() + 47 (AppDelegate.cpp:47)
24 appsname-mobile 0x1459c -[AppController applicationWillTerminate:] + 141 (AppController.mm:141)
What’s going on?