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

Stop Broadcast Extension by pressing indicator on native time doesn't make isScreenShareEnabled() to return false #446

Closed
mokuzuu opened this issue Jul 29, 2024 · 4 comments · Fixed by #520
Assignees
Labels
bug Something isn't working

Comments

@mokuzuu
Copy link

mokuzuu commented Jul 29, 2024

Describe the bug
Even after stopping screen share by pressing indicator on native time doesn't make isScreenShareEnabled() to return false.

SDK Version
2.0.12

iOS/macOS Version
iOS 17.5.1

Xcode Version
15.4
Swift 5

Steps to Reproduce

  1. Start broadcast extension by calling setScreenShare(enabled: true)
  2. Stop screen share by pressing indicator on native time

Expected behavior
Expect room.localParticipant.isScreenShareEnabled() to return false but true is returned.

Screenshots
If applicable, add screenshots to help explain your problem.

Logs
Please provide logs if you can.

@mokuzuu mokuzuu added the bug Something isn't working label Jul 29, 2024
@mokuzuu
Copy link
Author

mokuzuu commented Jul 30, 2024

I think I could workaround this by listening to iOS_BroadcastStopped notification from CFNotificationCenter

(DarwinNotificationCenter is extended by following https://gist.github.com/tomlokhorst/7fe49a03b8bac960eeaf2b991faa3680 so that callback can use async)

   func performAsyncTask() async {
        do {
            try await room.localParticipant.setScreenShare(enabled: false)
        } catch {
            print("An error occurred while updating screen share")
        }
  }

 func notificationCallback() {
        DispatchQueue.global().async {
            Task {
                await performAsyncTask()
            }
        }
    }

DarwinNotificationCenter.shared.addObserver(name: "iOS_BroadcastStopped", callback: notificationCallback)

@mokuzuu
Copy link
Author

mokuzuu commented Jul 30, 2024

Probably I can address fix for #444 with similar approach

@ashwin-nath-m
Copy link

@mokuzuu did u get this working? can u share your DarwinNotificationCenter class

@mokuzuu
Copy link
Author

mokuzuu commented Sep 2, 2024

@ashwin-nath-m
I could workaround like this

 @State var darwinNotificationCenterObservation: DarwinNotificationObservation?

 // Define an async function to perform the async task
    func performAsyncTask() async {
        do {
            try await room.localParticipant.setScreenShare(enabled: false)
        } catch {
            print("An error occurred while updating screen share")
        }
    }
    
    // function that matches the C function pointer type
    func notificationCallback() {
        // Dispatch to handle async code
        DispatchQueue.global().async {
            Task {
                await performAsyncTask()
            }
        }
    }
    
    
    func setupNotifications() {
        // We need to store the value in variable/state to keep notification active.
        darwinNotificationCenterObservation = DarwinNotificationCenter.shared.addObserver(name: "iOS_BroadcastStopped", callback: notificationCallback)
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants