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

[Enhancement/Bug] Don't crash if a BT controller is active and the current app uses keymapping #118

Open
HealsCodes opened this issue Jul 26, 2023 · 0 comments

Comments

@HealsCodes
Copy link

HealsCodes commented Jul 26, 2023

Currently whenever a supported bluetooth controller is connected (tested with a DS5) and the active application has Keymapping enabled it will crash in specialized static PlayController.handleEvent(_:_:) if any button or the touchpad are used.

Disabling Keymapping will fix this crash and allow the application to interact with or ignore the controller, however this isn't really documented anywhere and it would be nice if PlayTools would handle this case better and for example display an error about active keymapping + controller instead of crashing the app.

Tested with: PlayCover 3.0.0 (406), M2 MacBookAir, macOS 13.5 (22G74)

Steps to reproduce:

  • right click any app in PlayCover
  • open the settings and enable 'Keymapping'
  • connect a supported bluetooth controller to your mac (I tested with a DS5)
  • start the app
  • once started press a few buttons on the controller / use the touchpad

Here's an excerpt of the interesting parts of crashing Honkay StarRail that way but it works in any application:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               hkrpg [51244]
Path:                  /Users/USER/Library/Containers/io.playcover.PlayCover/Honkai: Star Rail.app/hkrpg
Identifier:            com.HoYoverse.hkrpgoversea
Version:               1.2.0 (3)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2023-07-26 19:25:19.3210 +0200
OS Version:            macOS 13.5 (22G74)
Report Version:        12

Time Awake Since Boot: 28000 seconds
Time Since Wake:       3359 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000090
Exception Codes:       0x0000000000000001, 0x0000000000000090

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [51244]

VM Region Info: 0x90 is not in any region.  Bytes before following region: 105553518919536
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-/rwx SM=NUL  ...(unallocated)

Kernel Triage:
VM - (arg = 0x0) pmap_enter retried due to resource shortage
VM - (arg = 0x0) pmap_enter retried due to resource shortage
VM - (arg = 0x0) pmap_enter retried due to resource shortage
VM - (arg = 0x0) pmap_enter retried due to resource shortage
VM - (arg = 0x0) pmap_enter retried due to resource shortage


Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   UnityFramework                	       0x11a2976c4 0x1112e4000 + 150681284
1   UnityFramework                	       0x11a6769cc 0x1112e4000 + 154741196
2   UnityFramework                	       0x11a67311c 0x1112e4000 + 154726684
3   UnityFramework                	       0x11a673058 Unityplcrash_signal_handler + 24
4   libsystem_platform.dylib      	       0x197066a24 _sigtramp + 56
5   ???                           	0xffff800100eac1f0 ???
6   PlayTools                     	       0x100eac39c specialized static PlayController.handleEvent(_:_:) + 424
7   PlayTools                     	       0x100eaa220 thunk for @escaping @callee_guaranteed (@guaranteed GCExtendedGamepad, @guaranteed GCControllerElement) -> () + 80
8   libdispatch.dylib             	       0x196e86874 _dispatch_call_block_and_release + 32
9   libdispatch.dylib             	       0x196e88400 _dispatch_client_callout + 20
10  libdispatch.dylib             	       0x196e96bf8 _dispatch_main_queue_drain + 928
11  libdispatch.dylib             	       0x196e96848 _dispatch_main_queue_callback_4CF + 44
12  CoreFoundation                	       0x197157c54 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
13  CoreFoundation                	       0x1971153d4 __CFRunLoopRun + 1992
14  CoreFoundation                	       0x1971144b8 CFRunLoopRunSpecific + 612
15  HIToolbox                     	       0x1a0966df0 RunCurrentEventLoopInMode + 292
16  HIToolbox                     	       0x1a0966c2c ReceiveNextEventCommon + 648
17  HIToolbox                     	       0x1a0966984 _BlockUntilNextEventMatchingListInModeWithFilter + 76
18  AppKit                        	       0x19a33b97c _DPSNextEvent + 636
19  AppKit                        	       0x19a33ab18 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
20  AppKit                        	       0x19a32ef7c -[NSApplication run] + 464
21  AppKit                        	       0x19a3063cc NSApplicationMain + 880
22  AppKit                        	       0x19a55eb78 _NSApplicationMainWithInfoDictionary + 24
23  UIKitMacHelper                	       0x1ae78b960 UINSApplicationMain + 988
24  UIKitCore                     	       0x1c28c28e8 UIApplicationMain + 148
25  UnityFramework                	       0x1112fa8dc 0x1112e4000 + 92380
26  hkrpg                         	       0x1007c27b4 0x1007bc000 + 26548
27  dyld                          	       0x196cdff28 start + 2236

Thread 1:
0   libsystem_pthread.dylib       	       0x197032d8c start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib       	       0x197032d8c start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib       	       0x197032d8c start_wqthread + 0

Thread 4:
0   libsystem_pthread.dylib       	       0x197032d8c start_wqthread + 0

Thread 5:
0   libsystem_pthread.dylib       	       0x197032d8c start_wqthread + 0

Thread 6:: com.apple.uikit.eventfetch-thread
0   libsystem_kernel.dylib        	       0x196ff7f54 mach_msg2_trap + 8
1   libsystem_kernel.dylib        	       0x19700a280 mach_msg2_internal + 80
2   libsystem_kernel.dylib        	       0x197000bb8 mach_msg_overwrite + 604
3   libsystem_kernel.dylib        	       0x196ff82d0 mach_msg + 24
4   CoreFoundation                	       0x1971167e4 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                	       0x1971150c4 __CFRunLoopRun + 1208
6   CoreFoundation                	       0x1971144b8 CFRunLoopRunSpecific + 612
7   Foundation                    	       0x19808dfbc -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8   Foundation                    	       0x198102384 -[NSRunLoop(NSRunLoop) runUntilDate:] + 100
9   UIKitCore                     	       0x1c28c3e04 -[UIEventFetcher threadMain] + 104
10  Foundation                    	       0x19808753c __NSThread__start__ + 716
11  libsystem_pthread.dylib       	       0x197037fa8 _pthread_start + 148
12  libsystem_pthread.dylib       	       0x197032da0 thread_start + 8

Thread 7:
0   libsystem_pthread.dylib       	       0x197032d8c start_wqthread + 0

Thread 8:: NIO-ELT-0-#0
0   libsystem_kernel.dylib        	       0x196ffe0a0 kevent + 8
1   PlayTools                     	       0x100ffda6c specialized static KQueue.kevent(kq:changelist:nchanges:eventlist:nevents:timeout:) + 56
2   PlayTools                     	       0x100fe827c specialized Selector.whenReady0(strategy:onLoopBegin:_:) + 412
3   PlayTools                     	       0x100fe4cb0 SelectableEventLoop.run() + 380
4   PlayTools                     	       0x100fc8fb8 closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:parentGroup:selectorFactory:initializer:) + 328
5   PlayTools                     	       0x100fcc830 partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:parentGroup:selectorFactory:initializer:) + 36
6   PlayTools                     	       0x100fcea20 thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () + 24
7   PlayTools                     	       0x100fff478 closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) + 272
8   libsystem_pthread.dylib       	       0x197037fa8 _pthread_start + 148
9   libsystem_pthread.dylib       	       0x197032da0 thread_start + 8



huyvu8051 pushed a commit to huyvu8051/PlayTools that referenced this issue Aug 21, 2024
* Add DocC to PlayCover

* Update

* Add website to Readme

* Fix error sometimes cause by shell on startup
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