Thread issue for chat? v5.9+ and before too?

Although sendChatToGroup() works on a callback thread, it does not seem to work on a “fresh” thread. Similar for direct message.

You can validate this problem using the function attempt2chats() at bottom. A call to the function can be inserted around line 396 of the sample app’s MyMeetingActivity.java, after lines:

private void refreshToolbar() {
     if (mMeetingService.getMeetingStatus() == MeetingStatus.MEETING_STATUS_INMEETING) {

That refreshToolbar() function is called during a callback from OnMeetingStatusChanged(), and as such, the calling thread supports outgoing chat. (If you want the full MyMeetingActivity file to test with, please contact me. Does zoom allow posting of such samples as a ‘gist’ publicly?)

Version
This applies to the Android SDK v5.9+, and probably before too (I recall seeing this behavior several releases ago).

Steps To Reproduce

  1. Insert attempt2chats() into sdk sample code as mentioned above
  2. Launch different (normal) client into meeting beforehand, to receive chats and validate.
  3. Join meeting with modified sample client
  4. Validate that group chat has one message, but not two.
  5. Validate there is no error result for 2nd attempt in separate, fresh thread; it is echoed to sending client but not to actual group chat.

Smartphone:

  • Device: Pixel 1,3
  • OS: android 10, 12 respectively

Additional context
Important: validate this with at least 2 attendees in the group chat; message is echoed to local sample client but NOT to others

=============

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import us.zoom.sdk.MobileRTCSDKError;
import us.zoom.sdk.ZoomSDK;
import us.zoom.sdk.InMeetingChatController;

/**
 * class which shows that zoom android SDK v5.9x cannot chat from fresh thread.
 * insert call to this around line 396 of MyMeetingActivity.java, which has lines:
 *     private void refreshToolbar() {
 *        if (mMeetingService.getMeetingStatus() == MeetingStatus.MEETING_STATUS_INMEETING) {
 */

public class TwoChats {
    private static final String TAG = "chatThreadIssue";

    private void attempt2chats(Context context) {
        // hack to test chat from zoom callback vs fresh thread
        Toast.makeText(context, "attempting chat...", Toast.LENGTH_SHORT).show();
        final MobileRTCSDKError result = ZoomSDK.getInstance().getInMeetingService()
                .getInMeetingChatController()
                .sendChatToGroup(
                        InMeetingChatController.MobileRTCChatGroup.MobileRTCChatGroup_All,
                        "test message in callback");

        if (result != MobileRTCSDKError.SDKERR_SUCCESS) {
            Toast.makeText(context, "chat error in callback: " + result, Toast.LENGTH_SHORT).show();
            Log.d(TAG, "got chat err in callback: " + result);
        }

        Runnable freshThread = new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1000); // wait for previous chatting to be "not too frequent"
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                final MobileRTCSDKError result = ZoomSDK.getInstance().getInMeetingService()
                        .getInMeetingChatController()
                        .sendChatToGroup(
                                InMeetingChatController.MobileRTCChatGroup.MobileRTCChatGroup_All,
                                "test message in thread");

                if (result != MobileRTCSDKError.SDKERR_SUCCESS) {
                    Log.d(TAG, "got chat err in thread: " + result);
                }
            }
        } ;

        new Thread(freshThread).start();
    }
}

Hi @larham, thanks for using the dev forum.

When using the SDK, you must call all methods from the main thread. Usage of the SDK outside of the main thread is not supported. :slightly_smiling_face:

Thanks!

Thanks, now that I know what to look for, I found SDK Initialization which states “Main Thread
Please note that SDK initialization and all API call must run in Main Thread.”

My 2 cents: this feels like a restriction worthy of mentioning elsewhere in docs, perhaps in language not associated with initialization. And removing the restriction even better :slight_smile:

Hi @larham,

Thanks for the feedback! We definitely have some improvements to make in our documentation and will make note of this in particular as we continue working on improving our SDK documentation.

Thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.