Skip to content

sdp: Fix m-line ordering when merging offers#888

Merged
algesten merged 1 commit intoalgesten:mainfrom
Route-8:m-line-ordering
Mar 7, 2026
Merged

sdp: Fix m-line ordering when merging offers#888
algesten merged 1 commit intoalgesten:mainfrom
Route-8:m-line-ordering

Conversation

@bekriebel
Copy link
Copy Markdown
Contributor

When an offer is sent by a client and the SFU at the same time, we may have a conflict that requires one side to roll back their changes and renegotiate after accepting the incoming offer.

However, at least with Chrome, the client may still expect the m-lines to match their ordering even after a rollback.

To accomodate this, only increase the index on actions that produce an m-line to ensure an expected increment and, when merging, ensure that the original changes are prepended to the new offer instead of appending them and changing the m-line order.

Fixes #887

@algesten
Copy link
Copy Markdown
Owner

algesten commented Mar 7, 2026

@bekriebel looks good, but I think that WIP commit is not supposed to be there right?

@bekriebel
Copy link
Copy Markdown
Contributor Author

Oh, whoops. That was supposed to be a different test branch. I'll clean that up today. Sorry about that.

When an offer is sent by a client and the SFU at the same time, we may
have a conflict that requires one side to roll back their changes and
renegotiate after accepting the incoming offer.

However, at least with Chrome, the client may still expect the m-lines
to match their ordering even after a rollback.

To accomodate this, only increase the index on actions that produce an
m-line to ensure an expected increment and, when merging, ensure that
the original changes are prepended to the new offer instead of appending
them and changing the m-line order.

Fixes algesten#887
Copy link
Copy Markdown
Owner

@algesten algesten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks!

@bekriebel
Copy link
Copy Markdown
Contributor Author

@algesten Fixed, and rebased on the current main. I actually ended up resolving my issue in a different way in our codebase, so this is no longer blocking me. However, I do think it is still the correct way to handle these values.

I moved that temp commit into it's own PR, #893. This was something else that I found that was also a red herring for my issue, but figured I'd open it in case you want to match the RFC.

@algesten algesten merged commit 86173c4 into algesten:main Mar 7, 2026
56 checks passed
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.

SDP m-lines included out of order when using merge()

2 participants