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

Fix the macOS version for Monterey #68

Merged
merged 5 commits into from
Jun 5, 2022

Conversation

semvis123
Copy link
Contributor

@semvis123 semvis123 commented Mar 28, 2022

This brings back functionality, but it still consumes one full cpu core, so it isn't ready for merging. Closes #62

@semvis123
Copy link
Contributor Author

Seems to be working correctly now.
image
I don't know if this breaks the versions before Monterey.

@semvis123 semvis123 changed the title Fix the macOS version Fix the macOS version for Monterey May 23, 2022
@Plutoberth
Copy link
Owner

Plutoberth commented May 24, 2022

Did they break the API in Monterey?
LGTM anyway, let me know when you want this to be merged (as it's still marked as draft)

@Plutoberth Plutoberth closed this May 24, 2022
@Plutoberth Plutoberth reopened this May 24, 2022
@semvis123
Copy link
Contributor Author

semvis123 commented May 25, 2022

Did they break the API in Monterey?

Kinda, they changed some threading related behavior I think.

let me know when you want this to be merged

I just tested it on an older macOS version, and it appears to be broken. I guess I could check on which version it is and use the old method on older macOS.

@semvis123
Copy link
Contributor Author

Okay, it seems to be working correctly on both macOS versions (High Sierra and Monterey) now.

@semvis123 semvis123 marked this pull request as ready for review May 25, 2022 18:44
@Plutoberth
Copy link
Owner

It's weird to me that such a fundamental thing would break on macOS. I think that it must be that we're doing something wrong, that probably introduces additional bugs. Can we try to find a solution that works on both versions?

@semvis123
Copy link
Contributor Author

semvis123 commented May 26, 2022

It's weird to me that such a fundamental thing would break on macOS.

Yeah it's indeed weird, even some Xcode provided bluetooth tools seem to be broken.

Can we try to find a solution that works on both versions?

Yeah I guess that's a good idea, I will setup a High Sierra VM (to make testing a bit faster) and test a few more things.

@semvis123
Copy link
Contributor Author

I will setup a High Sierra VM

This didn't work, couldn't get bluetooth working in a macOS VM.

However I did discover a solution that works on both versions, but wakes the cpu every second on Monterey (which should only be needed on High Sierra)

std::unique_lock<std::mutex> lk(macOSBluetoothConnector->disconnectionMutex);
while (macOSBluetoothConnector->running) {
    [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:.1]];
    macOSBluetoothConnector->disconnectionConditionVariable.wait_for(lk, std::chrono::milliseconds(1000), [&]() {
        return !macOSBluetoothConnector->running;
    });
}

lk.unlock();

I guess it is a decent solution for both versions.

@Plutoberth
Copy link
Owner

Not quite sure that I understand the macOS concurrency model, but it sounds like it works this way. Merging :)

@Plutoberth Plutoberth merged commit c360d10 into Plutoberth:master Jun 5, 2022
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

Successfully merging this pull request may close these issues.

Not working on macOS Monterey
2 participants