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

[Regression] RPCS3 crashes if airpods are taken off on macOS. #12528

Closed
mygizli04 opened this issue Aug 18, 2022 · 17 comments · Fixed by #12805
Closed

[Regression] RPCS3 crashes if airpods are taken off on macOS. #12528

mygizli04 opened this issue Aug 18, 2022 · 17 comments · Fixed by #12805

Comments

@mygizli04
Copy link

mygizli04 commented Aug 18, 2022

Quick summary

After #12246 if I take my airpods off while a game is running, RPCS3 crashes.

Details

After #12246 if I take my airpods off while a game is running, RPCS3 crashes. This does not occur when I change my default audio device before taking them off, or with wired headphones. Disconnecting by turning off bluetooth also does not trigger the issue.

Build with regression

v0.0.23-13872-98b730c8

Attach two log files

#12246 (bad) : RPCS3.log
#12300 (good) : RPCS3.log

System configuration

macOS 13.0 beta (22A5295i)
Apple M1 chip
Airpods Pro

@Megamouse
Copy link
Contributor

Please try this PR: #12534
Upload a log containing a crash using that build. (If it is fixed by chance then upload it anyway)

@mygizli04
Copy link
Author

mygizli04 commented Aug 19, 2022

It is not fixed.
RPCS3.log

@Megamouse
Copy link
Contributor

Please try again with the next build.

Also, what does it mean "I take my airpods off" ?
Are they turned off automatically?
What I'm trying to say is: does it also happen with any other headset?

@mygizli04
Copy link
Author

mygizli04 commented Aug 19, 2022

I'm not really sure how it works, so here's a list of my output devices right now. I have my airpods on right now so it is the default audio device:

image

If I take them off ( as in take them both off from my ears, and they automatically detect that they've been taken off ), it is no longer the default audio device ( but I believe it stays connected ) ( also produces the crash ):

image

But it is not the changing of the output device that's triggering the crash, because if I change it manually it does not crash.

I don't have another bluetooth headphone to test, but if I, for example, use a display ( or wired headphones ) and unplug that even though the device disappears ( and the default audio device is changed ) RPCS3 still does not crash:

image

image

Here's the crash with that build:
RPCS3.log

@Megamouse
Copy link
Contributor

So it only happens if the default device are the airpods and they go to sleep so to speak.
What if you don't use another default device but select the airpods in the audio settings of rpcs3 ?

@mygizli04
Copy link
Author

When I picked the airpods manually in RPCS3 settings it did not crash.

RPCS3.log

@Megamouse
Copy link
Contributor

Well. This seems like an upstream cubeb bug.
I created a couple of issues on their github. Maybe someone will take a look.

@mygizli04
Copy link
Author

mygizli04 commented Aug 19, 2022

Could you link me the issue if it's not a problem so I can subscribe to it? Seems weird to me that it was a upstream bug since it was a RPCS3 update that introduced the issue but I suppose Cubeb got updated on that PR? Changing the audio device is a more than good enough workaround but I'd like to see it fixed by default as well.

@Megamouse
Copy link
Contributor

Megamouse commented Aug 19, 2022

The old code never tried to enumerate devices like this and also didn't react to device changes.
It simply tried to reconnect the default device if it got disconnected.
mozilla/cubeb#719

@shinra-electric
Copy link
Contributor

When listening to music, AirPods will pause the music if one of the airpods are removed from the ear. So it is likely the pause command is causing an issue.

@nastys
Copy link
Contributor

nastys commented Aug 24, 2022

I do not have AirPods, so I cannot reproduce the exact same issue, but for me, turning off Bluetooth while a BT audio device is selected as the output device does cause a crash sometimes.
RPCS3 build 14084-1fc01913:

Crashed Thread:        3  Dispatch queue: org.mozilla.cubeb

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Thread 0::  Dispatch queue: com.apple.main-thread
0   ???                           	    0x7ff8967ee9a8 ???
1   libsystem_kernel.dylib        	    0x7ff80755d6a2 mach_msg2_trap + 10
2   libsystem_kernel.dylib        	    0x7ff80756b67d mach_msg2_internal + 82
3   libsystem_kernel.dylib        	    0x7ff80756471a mach_msg_overwrite + 723
4   libsystem_kernel.dylib        	    0x7ff80755d989 mach_msg + 19
5   CoreFoundation                	    0x7ff807676987 __CFRunLoopServiceMachPort + 145
6   CoreFoundation                	    0x7ff8076753d4 __CFRunLoopRun + 1387
7   CoreFoundation                	    0x7ff8076747ef CFRunLoopRunSpecific + 560
8   HIToolbox                     	    0x7ff811407276 RunCurrentEventLoopInMode + 292
9   HIToolbox                     	    0x7ff811407086 ReceiveNextEventCommon + 679
10  HIToolbox                     	    0x7ff811406dc3 _BlockUntilNextEventMatchingListInModeWithFilter + 70
11  AppKit                        	    0x7ff80a6b7ccb _DPSNextEvent + 909
12  AppKit                        	    0x7ff80a6b6b4c -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1219
13  AppKit                        	    0x7ff80a6a9133 -[NSApplication run] + 586
14  libqcocoa.dylib               	       0x11c5e3a3a 0x11c5a9000 + 240186
15  QtCore                        	       0x119762d56 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 502
16  QtCore                        	       0x119766d22 QCoreApplication::exec() + 130
17  rpcs3                         	       0x100feffd6 main + 27910
18  dyld                          	       0x2087d32ea start + 2410

Thread 1:: com.apple.rosetta.exceptionserver
0   runtime                       	    0x7ff7ffdb28d0 0x7ff7ffdae000 + 18640
1   runtime                       	    0x7ff7ffdbe724 0x7ff7ffdae000 + 67364
2   runtime                       	    0x7ff7ffdc0124 0x7ff7ffdae000 + 74020

Thread 2:
0   runtime                       	    0x7ff7ffdd087c 0x7ff7ffdae000 + 141436

Thread 3 Crashed::  Dispatch queue: org.mozilla.cubeb
0   ???                           	    0x7ff8967ee9a8 ???
1   libsystem_kernel.dylib        	    0x7ff80756430e __pthread_kill + 10
2   libsystem_pthread.dylib       	    0x7ff80759bf7b pthread_kill + 263
3   libsystem_c.dylib             	    0x7ff8074e5ca9 abort + 123
4   libsystem_c.dylib             	    0x7ff8074e4fc2 __assert_rtn + 314
5   rpcs3                         	       0x101d6ec35 0x100fd7000 + 14253109
6   rpcs3                         	       0x101d63da6 0x100fd7000 + 14208422
7   rpcs3                         	       0x10112dcbb CubebBackend::GetDefaultDeviceAlt(AudioFreq, AudioSampleSize, AudioChannelCnt) + 203
8   rpcs3                         	       0x10112c8eb CubebBackend::device_collection_changed_cb(cubeb*, void*) + 203
9   rpcs3                         	       0x101d6f7bf 0x100fd7000 + 14256063
10  libdispatch.dylib             	    0x7ff80741b85b _dispatch_call_block_and_release + 12
11  libdispatch.dylib             	    0x7ff80741caa4 _dispatch_client_callout + 8
12  libdispatch.dylib             	    0x7ff807422b24 _dispatch_lane_serial_drain + 694
13  libdispatch.dylib             	    0x7ff807423614 _dispatch_lane_invoke + 366
14  libdispatch.dylib             	    0x7ff80742daf9 _dispatch_workloop_worker_thread + 762
15  libsystem_pthread.dylib       	    0x7ff807598ce3 _pthread_wqthread + 326
16  libsystem_pthread.dylib       	    0x7ff807597c67 start_wqthread + 15

The function names are exposed (except 5,6, and 9, which are apparently part of llvm::).

If I use USB headphones and disconnect them, it does not crash.

@nastys
Copy link
Contributor

nastys commented Aug 28, 2022

macOS 13.0 Beta 4 is out. Is the original issue fixed?

@shinra-electric
Copy link
Contributor

I am on macOS 13 beta 10.

I just tried testing this with my AirPods, and RPCS3 crashed immediately after removing both AirPods from my ears. (Note that removing just one does not cause the crash).

@kd-11
Copy link
Contributor

kd-11 commented Oct 11, 2022

This is a cubeb bug. The crash happens inside the library, we cannot fix it without forking the library and making modifications ourselves or upstream fixing it (this is why I hate relying on do-it-all 3rd party libraries). It also happens on all OSes if you disable the audio sink. The only difference is that macOS doesn't have an alternative while we have XAudio and FAudio for windows and linux which work correctly.

@shinra-electric
Copy link
Contributor

It looks like Megamouse already opened an issue for it with cubeb...

@Vestrel
Copy link
Contributor

Vestrel commented Oct 13, 2022

Try with #12805

@shinra-electric
Copy link
Contributor

@Vestrel Yes, #12805 fixes the issue for me on macOS Ventura.

When removing my AirPods the audio switched to my Mac, and replacing them switched the audio back as expected.

Good job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants