Azure / Communication

Azure Communication Services - SDKs and Release Notes
MIT License
319 stars 98 forks source link

[iOS] Weird issiues in 1.0.0 #282

Open devgokhan opened 3 years ago

devgokhan commented 3 years ago

We tested with iPhone to iPhone, 3 iPhone device and iPhone to Web. I will determine the devices with like this. A: Iphone 1, B: Iphone 2, X: Iphone 3, W: Web

We faced with this problems: 1- Sometimes camera is goes and never shown again. Every test was strange. In our first test we were 2 device in meeting. After 2 minute A and X device camera is gone (evet if cameras open). And camera never back even we close the meeting and rejoin anyway. In our second test we were 3 device in meeting. Those devices were A, B, and X. Test started with A and B device. Both device worked correctly more than 10 minute. Nothing strange happened. Anyway after X device joined to the meeting then A and B could not see X device camera. A device leaved from the meeting. Still there is no camera is shown (even we try close and reopen the cameras). After that A rejoined the meeting. A could see X however B devices could not see X. In our third test we tested with A and X device. Nothing happened. We could see our cameras more then 5 minute. In our fourth test we tested with A and W device. Same thing happened iPhone to Web test too. In some minutes neither web or iOS could not see their cameras. Even if they close and repopen, they couldn't see eachothers. In all test audio working correctly and remote participant still in the meeting. 2- Something starting strange, for example if first issue that I shared happened, after that we press Hangup button, application is freezing. Sometimes freezes some seconds sometimes freezes some minutes. In some cases we must have force quit the app. In some cases freezing is gone however when we try to join a new meeting we were unable to that. When we call join nothing happening, no state returns us in delegate and join completion.

I have a meeting IDs. You can check the logs maybe? Probably we made a test between 13:30-14:30 GMT +0 We did iOS to iOS tests with those meeting IDs: A413FA94-BAFA-448D-B75A-B3E371DD89EF -> Problems happened A413FA94-BAFA-448D-B75A-B3E371DD89E1 -> Problems happened A413FA94-BAFA-448D-B75A-B3E371DD89E2 -> No issue happened A413FA94-BAFA-448D-B75A-B3E371DD89E3 -> No issue happened

X device user display name was: aaa zzz -> Which is camera gone problems happens with this device.

iOS to Web tests meeting Id not available.

B device blogfiles here: blogfiles.zip

If you need extra information please let me know, I can share with you.

raosanat commented 3 years ago

Blogs have multiple logs and the callId you mentioned does not match with anything in the logs. When you say device camera is gone do you mean rendering of the video has stopped ?

Would it be possible to

  1. Uninstall the app and reproduce the scenario. If you end up making multiple calls please let us know the callId , the one's posted above seems incorrect.
  2. Use QuickTime player to record the screen of the phone and send it to us if possible, instructions here ? if the application is confidential or proprietary you can ignore it .
  3. Can you write step by step what action was performed on what device. For e.g.
1. Device A , outgoing audio call was placed to Device B
2. Device B , incoming call received and accepted with video 
3. Call ongoing. 
     a. Device A can see incoming video from Device B. 
     b. Device B cannot see incoming video from Device A. => Expected as Device A placed outgoing audio call.
4. Device A, local video turned on.
5. Device B, cannot see incoming video. => ERROR, expect to see incoming video from Device B on Device A.
devgokhan commented 3 years ago

Yes.. I mean Rendering has stopped. Stopped both devices remote participant renderer view. When video rendering has stopped we did some tests to reopen camera but we could not succeed. We tried closing and reopening our cameras multiple times however hadn't render the camera too. I had some logs which can give us hint:

---> Meeting -> remoteParticipantContext onVideoStreamsUpdated() for participant: aaa zzz ---> Meeting -> checkCameraStateOfCurrentActiveCameraShownRemoteParticipant activeCameraShownRemoteParticipant is nil ---> Meeting -> cleanRemoteParticipantView() ---> Meeting -> remoteVideoStreamsJob() targetRemoteParticipantView creating for aaa zzz.. ---> Meeting -> remoteVideoStreamsJob() targetRemoteParticipantView created for aaa zzz ---> Meeting -> remoteVideoStreamsJob() participantView avaible for aaa zzz ---> Meeting -> remoteVideoStreamsJob() participant: aaa zzz - videoStreamsCount: 1 - returns: true ---> Meeting -> focusedRemoteParticipantChange working for aaa zzz

As you can see I am able to see remote participant camera status changes from delegate. In logs it says created remote participant view to render it -> it means RendererView created.

---> Meeting -> remoteVideoStreamsJob() participantView avaible for aaa zzz -> This line says RendererView has been added to container view.

With looking the logs I can say everything should be OK and video needs to be showed, however it is not. Strange thing sometimes it happened both device at the same time like explained above.

This problem happened in only tests with device X. When I tried A to B it didn't. In the test of A to X, A B to X, W to X it is happened. I am not sure this can be a problem or not, X device had been closed because of charge is over, after some minutes we made a test again and this problem didn't happened. (Camera is gone problem)

In first scenerio step by step; -> Both device A and X were talking - both device remote video and local video was open -> In a 2 minute both device remote videos was gone. -> We tried close video and reopen video, but still we were unable to see remote video but audio was active we could hear each other. -> One of device leave the meeting and come back, however still nobody could see each others remote videos. -> Another device tried to leave meeting with pressing Hangup - screen frozen.

When I faced with problems again I will give you more detailed informations. If I can I will share video too.

devgokhan commented 3 years ago

I am giving extra informations for HangUp problem.. Code:

print("Meeting -> Hangup starting..")
let options = HangUpOptions()
call.hangUp(options: options, completionHandler: { [weak self] (error) in
                if let error = error {
                    print("Meeting -> Hangup error: \(error.localizedDescription)")
                }
                print("Meeting -> Hangup completed!")
                print("Meeting -> Will dismiss..")
                self?.dismiss()
})

Meeting -> Hangup starting.. <<-- Frozen here around

Then after some minutes I pressed hangup again, meeting closed successfully.. However I never join the meeting again until reopen the app.. This is not happens when everything normal.

This is callAgent code:


self.callClient = CallClient()
        print("Meeting -> setupMeeting() - Creating Agent")
        self.callAgentOptions = CallAgentOptions()
        self.callAgentOptions?.displayName = self.userFullName
        if let usCr = self.userCredential {
            self.callClient?.createCallAgent(userCredential: usCr, options: callAgentOptions) { [weak self] (agent, error) in
                if error != nil {
                    Utils.log("Meeting -> setupMeeting() ERROR: It was not possible to create a call agent.")
                } else {
                    Utils.log("Meeting -> setupMeeting() Call agent successfully created.")
                    self?.callAgent = agent
                    self?.startLocalVideo(isStart: true)
                }
            }
        } else {
            print("Meeting -> WARNING! setupMeeting() has nil userCrediantal so it will never worked!")
        }

Sometimes callAgent is nil when using it for call .join, sometimes no call state updates after join called..

devgokhan commented 3 years ago

Hi I think one of the reason for this problem is, even remote participant camera is open, remoteStreams count is 0

--> Meeting -> **** findMostActiveRemoteParticipantAndCheckViews() remoteParticipant check works because conditions requires that! targetRemoteParticipantView is nil! - remoteRenderer isnil! ****
..
---> Meeting -> remoteVideoStreamsJob() participant: aaaa bbbbb - videoStreamsCount: 0 - returns: false
raosanat commented 3 years ago

@devgokhan Please give us time to look at this, but you haven't done this what i mentioned before.

Uninstall the app and reproduce the scenario. If you end up making multiple calls please let us know the callId , the one's posted above seems incorrect.

devgokhan commented 3 years ago

Hi. I shared today's .blog files:

Archive.zip

raosanat commented 3 years ago

@devgokhan please try this for the hangup

func applicationWillTerminate(_ application: UIApplication) { hangUp() }

    func hangUp() -> Void {
        os_log("[HANGUP] Hangup called")
        guard let call = self.call else {
            os_log("[HANGUP] Empty call object")
            return
        }
        let group = DispatchGroup()

        os_log("[HANGUP] DispatchGroup wait")
        group.enter()
        os_log("[HANGUP] Calling call hanup")
        call.hangUp(options: HangUpOptions()) { (error) in
            if (error == nil) {
                os_log("[IncomingCall] Hangup was successfull")
            }
            group.leave()
        }
        group.wait()
        os_log("[HANGUP] Exiting")
    }
devgokhan commented 3 years ago

Hi thank you @raosanat we tested it. This mostly resolves the issue. However one thing you need to do I will explain. If we use DispatchGroup and then call.hangUp, completion block never works. So because completion block never works, we are unable to call group.leave(). And because of we can't call group.leave(), after app force quit and then reopen it quickly people that testing the app with using TestFlight, sees App Crash Report popup. This means app is crashes at the start, but app opens successfully. This means because we can't call .leave() previous session of app crashes and we are seeing previous app crash report popup when we open new session of the app.

To resolve this seems you need to do something in SDK. I found a quick solution for this. This is my temp solution:

call.hangUp(options: options, completionHandler: { (error) in 
  ...
}
DispatchQueue.global(qos: .background).asyncAfter(deadline: .now() + 1.0) {
      if (dispatchGroupLeftAlready == false) {
            group.leave()
      }
}
...
group.wait()

For permanent solution maybe you need call SDK's hangup completion block from inside of the DispatchQueue.global(qos: .background)

Another people seems facing this problems too : https://stackoverflow.com/questions/46478041/dispatchgroup-wait-not-waiting