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

Shaka Player version 3.2.x and 3.3.x dispatch two adaptation events before init? #5480

Closed
whatever1211 opened this issue Aug 14, 2023 · 2 comments · Fixed by #5492
Closed
Labels
priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@whatever1211
Copy link

Have you read the Tutorials?
Yes, we have.

Have you read the FAQ and checked for duplicate open issues?
Yes, we have.

What version of Shaka Player are you using?
We were using v3.1.2 version previously. And recently upgrade to latest v3.3.19 version. Don't want to upgrade to v4 version for easier maintain.

Please ask your question
We saw that after upgrade to 3.2.x and 3.3.x version. Whenever we init shaka and play stream. Before init complete, there are always 2 adapation events dispatched instead of 1 as in 3.1.x version.
We want to ask what is the reason behind this behaviour. Is it intended? Or a bug? If it is intended, why does it behave like that?
We have tried to set configure abr enabled: false but still 2 adapation events are dispatched.
2_Adapation_Events

@whatever1211 whatever1211 added the type: question A question from the community label Aug 14, 2023
@whatever1211
Copy link
Author

whatever1211 commented Aug 14, 2023

After I check the code. I saw where the problem lie.

Version 3.3.19 - player.js - onLoad_

    if (!activeVariantTrack) {
      initialVariant = this.chooseVariant_();
      goog.asserts.assert(initialVariant, 'Must choose an initial variant!');
      this.switchVariant_(initialVariant, /* fromAdaptation= */ true,
          /* clearBuffer= */ false, /* safeMargin= */ 0);

      // Now that we have initial streams, we may adjust the start time to align
      // to a segment boundary.
      if (this.config_.streaming.startAtSegmentBoundary) {
        const startTime = this.playhead_.getTime();
        const adjustedTime =
            await this.adjustStartTime_(initialVariant, startTime);

        this.playhead_.setStartTime(adjustedTime);
      }

      // Since the first streams just became active, send an adaptation event.
      this.onAdaptation_(null,
          shaka.util.StreamUtils.variantToTrack(initialVariant));
    }

Both
this.switchVariant_(initialVariant, /* fromAdaptation= */ true, /* clearBuffer= */ false, /* safeMargin= */ 0);
and
this.onAdaptation_(null, shaka.util.StreamUtils.variantToTrack(initialVariant));
dispatch adaptation events.

Since oldTrack is null and newTrack has value. Both adaptation events are dispatched, result to two adaptation events before init.

On old 3.1.x version.
this.switchVariant_(initialVariant, /* fromAdaptation= */ true, /* clearBuffer= */ false, /* safeMargin= */ 0);
will not dispatch adaptation event. Only
this.onAdaptation_()
dispatch adaptation event.

Can I, on 3.3.19 version,

  1. Remove this.onAdaptation_(null, shaka.util.StreamUtils.variantToTrack(initialVariant));
    Or
  2. Change fromAdaptation value from true to false this.switchVariant_(initialVariant, /* fromAdaptation= */ false, /* clearBuffer= */ false, /* safeMargin= */ 0);

To result with only one adaptation event before init?
Or is there special case where these 2 code lines are needed to dispatch adaptation event correctly?

@avelad
Copy link
Member

avelad commented Aug 16, 2023

@theodab can you review it? Thanks!!

@avelad avelad added type: bug Something isn't working correctly priority: P2 Smaller impact or easy workaround and removed type: question A question from the community labels Aug 18, 2023
@github-actions github-actions bot added this to the v4.4 milestone Aug 18, 2023
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Oct 17, 2023
@shaka-project shaka-project locked as resolved and limited conversation to collaborators Oct 17, 2023
Robloche pushed a commit to Robloche/shaka-player that referenced this issue Nov 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants