Skip to content

Conversation

@jstarpl
Copy link
Contributor

@jstarpl jstarpl commented Oct 23, 2025

About the Contributor

This pull request is posted on behalf of the NRK.

Type of Contribution

This is a: Bug fix

Current Behavior

We have found a issue where the timings of pieces are not monotonic.
This only affects infinite pieces, and probably only when multiGatewayMode is enabled.

How to reproduce:

In a blueprints adlibAction:

// Stop the previous (infinite) piece
await context.stopPiecesOnLayers(['myLayer'])

await insertPiecesTyped(context, 'current', {
	[...],
	sourceLayerId: 'myLayer',
	enable: { start: 'now' },
	lifespan: PieceLifespan.OutOnShowStyleEnd,
})

This results in a virtual piece being inserted to stop the previous infinite OutOnShowStyleEnd piece, at time getCurrentTime()+calculateNowOffsetLatency (this is correct).
Then a pieceInstance is inserted at time "now", which is later resolved using getCurrentTime().
In our case, this ends up in that the virtual piece ends up after the inserted Piece, thus instantly ending it.

New Behavior

The use of getCurrentTime()+calculateNowOffsetLatency is abandoned altogether. A new method, getNowInPlayout is added on the PlayoutModel that will return monotonic timestamps for a now value, considering any latency involved. This can be sampled throughout the timeline generation process to account for any latency, but ensure that subsequent calls will not return values before previously returned.

Testing

  • I have added one or more unit tests for this PR
  • I have updated the relevant unit tests
  • No unit test changes are needed for this PR

Affected areas

This PR affects the playout logic in general.

Time Frame

  • This is a critical bug for us, but not urgent to merge into upstream.

Other Information

Disclaimer: I have not gone through the other places where getCurrentTime() is used, so there might be other places calculateNowOffsetLatency should be used.

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

@jstarpl jstarpl force-pushed the fix/resolve-timeline-wrong-time-redux branch from ca00864 to 3ddd1fd Compare October 23, 2025 16:29
@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants