Unable to/How to join a different Scroll Sync Session

Product:
PDFTron Collab Client
Product Version: 2.0.0-alpha.13

Please give a brief summary of your issue:
A new scrollSyncSession is created by the Leader and as a follower, I want to join that new session. Get Error on join()

Please describe your issue and provide steps to reproduce it:
As a follower I have joined a session by the leader, and I am able to join the first session.
A new scrollSyncSession is created by the Leader and as a follower, I want to join that new session.
When I attempt join() the new session, this is the error I receive:

Error: Cannot return null for non-nullable field ScrollSyncSession.leaderId.

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Please see latest edit.

Hello brooke.harris,

Can you provide the code you are using to try to join the scroll sync session?
We have an example here in the react sample: useCurrentScrollSyncSession | WebViewer Real-time Collaboration

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron

Below is the code snippets we us to join and exit from the session.
We have noticed that active sessions list will occasionally contain 2 sessions of the same session ID so perhaps those are conflicting.
Regarding the useCurrentScrollSyncSession hook, yarn is telling us it can’t be found: error An unexpected error occurred: " https://registry.yarnpkg.com/@pdftron%2fcollab-react : Not found".
Is the package publicly accessible?

-----------------------CODE SNIPPET---------------------------

// when mode changes destroy or create a new scrollSyncSession or subscribe to newest
useEffect(() => {
  (async () => {
    if (!client || !document) {
      return;
    }
    if (mode === 'free') {
      stopSession();
      return;
    }

    if (
      (mode === 'my' && sharedByMe) ||
      (mode === 'witness' && isWitness())
    ) {
      if (client.ScrollSyncManager.activeSession) {
        stopSession();
      }

      session.current = await document.createScrollSyncSession();
    } else {
      const availableSessions = client.ScrollSyncManager.availableSessions;

      if (availableSessions?.length) {
        console.log(
          'new availableSessions?.length: ',
          availableSessions?.length
        );
        const index = availableSessions.length - 1;

        const availableSession = availableSessions[index];

        if (client.ScrollSyncManager?.activeSession !== availableSession) {
          stopSession();
        }

        if (client.ScrollSyncManager.canJoinSession) {
          try {
            await availableSession.join();
          } catch (e) {
            console.log('newest availableSession.join() error: ', e);
          }

          session.current = availableSession;
        }
      }
    }
  })();
}, [mode, client, document]);


// listen for scrollSyncSessionsChanged, and subscribe if not free and current user is not controller
useEffect(() => {
  // just want to check if creation and initial join works
  /*return;
  console.log('listen for scrollSyncSessionsChanged!!', lastSessionPing, mode)*/

  if (!client || !document) {
    return;
  }
  if (mode === 'free') {
    // if free, nothing.... above useEffect will stop the session
    return;
  }

  if ((mode === 'my' && sharedByMe) || (mode === 'witness' && isWitness())) {
    // if I am controller I have started session in above useEffect, I do not need to subscribe to anything here, that will remove my control.
    return;
  }

  const availableSessions = client.ScrollSyncManager.availableSessions;

  if (availableSessions?.length) {
    console.log(
      'restart availableSessions?.length: ',
      availableSessions?.length
    );
    console.log('active session: ', client?.ScrollSyncManager.activeSession);
    console.log(' session: ', session);
    console.log('availableSessions: ', availableSessions);
    console.log('=======================================================');
    const index = availableSessions.length - 1;

    const availableSession = availableSessions[index];

    if (
      client.ScrollSyncManager?.activeSession &&
      client.ScrollSyncManager?.activeSession !== availableSession
    ) {
      stopSession();
    }

    if (client.ScrollSyncManager.canJoinSession) {
      (async () => {
        try {
          await availableSession.join();
        } catch (e) {
          console.log('restart availableSession.join() error: ', e);
        }
      })();

      session.current = availableSession;
    }
  }
}, [lastSessionPing, client, document]);

------------------------SCREENSHOT------------------------------

what is the stable release version for @pdftron/collab-client?

Hello brooke.harris,

My apologies, it looks like our collab-react sample has been removed from the yarn registry since Collab is not deprecated.

You can get the current available scroll sessions with: Scroll Synchronization | WebViewer Real-time Collaboration
And then joining those available scroll sessions using: Scroll Synchronization | WebViewer Real-time Collaboration

The latest stable version is: 2.3.0-alpha.1

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron

Hey, I’m the working scrum master for the team here and the above issue is a major blocker for our current sprint. So if we are still having issues is somebody available to jump on a call and do a screen share? Also, should we be worried that the library is now deprecated? Are there plans to continue with something else? How long will it be supported? Thanks!

@pdftron/collab-client is deprecated and is no longer supported.

We have built a signification portion of our functionality off of the collab-client package. Will @pdftron/collab-client continue to be supported or is there a package that will replace this functionality?

Andrey here, Director of Product at PDFTron. I am free to jump on a call to walk through your options for building out collab: Calendly - Andrey Safonov. If you do not find time on Calendly, I can try to move things around. I am in EST timezone.

Hello brooke.harris,

Thank you for your patience, we have some questions and debugging steps:

  1. Exactly what steps are the leader and follower doing to get to this point?
  2. When the leader creates a new session, are they exiting/ending the first session first?
  3. When the follower joins the new session, have they exited out of the first session? (This should happen automatically by the client)

Can you also try these steps:

  • Can you please enable debug logs on the server like so:
const server = new CollabServer({
   logLevel: CollabServer.LogLevels.DEBUG,
   filterLogsByTag: CollabServer.LogTags.SCROLL_SYNC,
 })

and then reproduce and send us any logs they see on both the server and client.

  • Can you also try the latest version?

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron

I replied via email twice, but I will post my response here as well.

Hi Tyler,

Here is the following information:

Our webviewer instance exist on it’s own seperate page.

  • when the leader goes to the page, a session is started.
  • when the follower joins afterward, it joins the session fine.
  • problem occurs when leader leaves by clicking on another page and tries to navigate back to the webviewer page.
  • according to the logs the session is not ended when the leader leaves.
    when the leader navigates back to the webviewer a new session is created then ended immediately.
  • Please see previous console logs in ticket regarding seemingly duplicated sessions
    package versions:
    @pdftron/collab-client”: “^2.0.0-alpha.13”,
    @pdftron/webviewer”: “8.2.0-20211206”,
    logs:
    2022-09-29 13:12:39 info [SCROLL_SYNC]: User 5846f06e-8786-4483-a89c-586c53a43e63 started a scroll sync session on document 1974e7b2-43d4-4cba-b48d-459236aff4b3
    2022-09-29 13:12:44 info [SCROLL_SYNC]: User 0e66b377-8db3-4111-8d27-edf2fa6040c8 joined a scroll sync session 1664471559007-5846f1974e
    2022-09-29 13:12:51 info [SCROLL_SYNC]: User 5846f06e-8786-4483-a89c-586c53a43e63 started a scroll sync session on document 1974e7b2-43d4-4cba-b48d-459236aff4b3 <== when leader navigates back.
    2022-09-29 13:12:51 info [SCROLL_SYNC]: User 5846f06e-8786-4483-a89c-586c53a43e63 ended a scroll sync session 1664471559007-5846f1974e <== leader didn’t take any action, this just happens _ immediately after starting the session.

Thank you,
Brooke

Hello brooke.harris,

Thank you for the information, please keep all discussion for this topic here as emailing support@pdftron.com will automatically create new tickets (which will be hard to track). Thank you!

When the leader leaves the website, the scroll session is not cancelled. In this case you can call: Scroll Synchronization | WebViewer Real-time Collaboration before the leader leaves.

What could be happening is since the session isn’t cancelled, when they open a new session it checks if they have any current sessions open then closes them.

  1. Leader creates session
  2. User joins
  3. Leader leaves page before calling ScrollSyncSession.exit()
  4. Leader rejoins page
    4.1. Leader creates new session
    4.2. Collab checks if user has another session made
    4.3. Collab closes the session
    4.4 Session is made

So tracking the onbeforeunload event, you can end the scroll sync session

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron

Additional errors we are seeing:

Sometimes when leader starts scroll sync session, leader will lose the ability to scroll. Not sure how to reproduce consistently and not seeing errors in console.

When the leader starts a scroll sync session follower isn’t joining the session even though it sees the active session. Sometimes follower will be able to join session after refreshing, but still showing the same error in console.
Error: Cannot return null for non-nullable field ScrollSyncSession.leaderId.