Bug audio enginge cocos 3.8.7 on ios

i got this crash log :frowning:

Exception Type:  EXC_BAD_ACCESS (SIGKILL)
Exception Subtype: KERN_PROTECTION_FAILURE at 0x000000000000729c
Exception Codes: 0x0000000000000002, 0x000000000000729c
VM Region Info: 0x729c is not in any region.  Bytes before following region: 4336487780
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                   1027a0000-1027bc000 [  112K] r-x/r-x SM=COW  /var/containers/Bundle/Application/8DD643D4-FB58-49A7-92B2-32515BF27B9C/GameClient-mobile.app/GameClient-mobile
Termination Reason: CODESIGNING 2 Invalid Page

Triggered by Thread:  6


Kernel Triage:
VM - (arg = 0x0) CL - 

Thread 0 name:
Thread 0:
0   libsystem_kernel.dylib        	0x00000001e5e0ee8c madvise + 8 (:-1)
1   libsystem_malloc.dylib        	0x00000001a564c688 <deduplicated_symbol> + 16 (:-1)
2   libsystem_malloc.dylib        	0x00000001a5642040 _xzm_xzone_free_block_to_small_chunk + 660 (xzone_malloc.c:3791)
3   OpenAL                        	0x000000023334d5cc OALSource::~OALSource() + 172 (oalSource.cpp:171)
4   OpenAL                        	0x0000000233334df4 OALContext::CleanUpDeadSourceList() + 424 (oalContext.cpp:252)
5   OpenAL                        	0x00000002333356f8 OALContext::RemoveSource(unsigned int) + 496 (oalContext.cpp:509)
6   OpenAL                        	0x0000000233342124 alDeleteSources + 408 (oalImp.cpp:1816)
7   GameClient-mobile        	0x00000001027eef9c cc::AudioEngineImpl::~AudioEngineImpl() + 180
8   GameClient-mobile        	0x00000001027ef154 cc::AudioEngineImpl::~AudioEngineImpl() + 12
9   GameClient-mobile        	0x00000001027e7a0c cc::AudioEngine::end() + 68
10  GameClient-mobile        	0x0000000102902b24 cc::Engine::destroy() + 48
11  GameClient-mobile        	0x00000001029029fc cc::Engine::~Engine() + 32
12  GameClient-mobile        	0x00000001027e5ed4 cc::CocosApplication::~CocosApplication() + 192
13  GameClient-mobile        	0x00000001027e594c cocos_destroy() + 108
14  GameClient-mobile        	0x00000001029ac234 -[AppDelegateBridge applicationWillTerminate:] + 48
15  UIKitCore                     	0x0000000198a23a20 -[UIApplication _terminateWithStatus:] + 196 (UIApplication.m:7581)
16  UIKitCore                     	0x0000000197a0c0d8 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 112 (_UISceneLifecycleMultiplexer.m:819)
17  UIKitCore                     	0x000000019826f684 -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:] + 164 (_UISceneLifecycleMultiplexer.m:482)
18  UIKitCore                     	0x0000000198a1f1c0 -[UIApplication workspaceShouldExit:withTransitionContext:] + 164 (UIApplication.m:4237)
19  FrontBoardServices            	0x00000001af54fc54 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2 + 72 (FBSWorkspaceScenesClient.m:635)
20  FrontBoardServices            	0x00000001af51ed38 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 168 (FBSWorkspace.m:445)
21  FrontBoardServices            	0x00000001af54fbf4 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke + 128 (FBSWorkspaceScenesClient.m:632)
22  libdispatch.dylib             	0x000000019cf54584 _dispatch_client_callout + 16 (client_callout.mm:85)
23  libdispatch.dylib             	0x000000019cf3fab0 _dispatch_block_invoke_direct + 284 (queue.c:515)
24  FrontBoardServices            	0x00000001af51e8ac __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 52 (FBSSerialQueue.m:285)
25  FrontBoardServices            	0x00000001af51e748 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 240 (FBSSerialQueue.m:309)
26  FrontBoardServices            	0x00000001af51e7b0 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 28 (FBSSerialQueue.m:322)
27  CoreFoundation                	0x0000000194fad92c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1970)
28  CoreFoundation                	0x0000000194fad744 __CFRunLoopDoSource0 + 172 (CFRunLoop.c:2014)
29  CoreFoundation                	0x0000000194fad604 __CFRunLoopDoSources0 + 332 (CFRunLoop.c:2059)
30  CoreFoundation                	0x0000000194fadf20 __CFRunLoopRun + 840 (CFRunLoop.c:2969)
31  CoreFoundation                	0x0000000194fafadc CFRunLoopRunSpecific + 572 (CFRunLoop.c:3434)
32  GraphicsServices              	0x00000001e1dd5454 GSEventRunModal + 168 (GSEvent.c:2196)
33  UIKitCore                     	0x00000001979d1274 -[UIApplication _run] + 816 (UIApplication.m:3845)
34  UIKitCore                     	0x000000019799ca28 UIApplicationMain + 336 (UIApplication.m:5540)
35  GameClient-mobile        	0x00000001027bc2e0 main + 132 (main.mm:38)
36  dyld                          	0x00000001bba41f08 start + 6040 (dyldMain.cpp:1450)

Termination Reason: CODESIGNING 2 Invalid Page : Normally that means your signing got the problem.

Pls try: 1.Re-sign the Application 2.Check Build Configuration

Thanks for the reply @Tom_k. I think there’s a problem with the audio because the crash log only appears when I open the app, then kill it, and repeat this process 6–7 times.

@Tom_k i have already fixed that bug with code like this in xcode

- (void)applicationWillTerminate:(UIApplication *)application {
    [[SDKWrapper shared] applicationWillTerminate:application];
// [appDelegateBridge applicationWillTerminate:application];

       
}

The crash log no longer appears after multiple attempts. However, does commenting out the code as shown have any impact?

The commented code, which handle cleanup tasks related to the Cocos engine, such as:

  • Save game data and user progress
  • Release engine resources and memory
  • Stop running tasks and threads
  • Execution engine’s exit cleanup logic

“applicationWillTerminate” event which called when user quits the application. If forcefully killing application may lead to unexpected issues including crash.