Skip to content

Conversation

@zibet27
Copy link
Collaborator

@zibet27 zibet27 commented Jul 14, 2025

Subsystem
Ktor Client WebRtc

Motivation
The data channel is an important part of the WebRTC protocol. I've implemented the common API and added stubs to existing engines. In the following commits, I will add real implementations.
Please review.

@zibet27 zibet27 requested review from Mr3zee, bjhham and e5l July 14, 2025 13:53
@zibet27 zibet27 self-assigned this Jul 14, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 14, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@zibet27 zibet27 force-pushed the zibet27/ktor-client-webrtc-datachannels branch from b4ea915 to 93ecff0 Compare July 14, 2025 13:56
@Mr3zee
Copy link
Member

Mr3zee commented Jul 14, 2025

@zibet27 is there a resource I can use to read about data channels?

@zibet27
Copy link
Collaborator Author

zibet27 commented Jul 14, 2025

@zibet27 is there a resource I can use to read about data channels?

@Mr3zee Sorry, forgot to add this link to the description.

@zibet27 zibet27 force-pushed the zibet27/ktor-client-webrtc-datachannels branch from 93ecff0 to 0ba2ff7 Compare July 14, 2025 15:25
@zibet27 zibet27 requested a review from bjhham July 14, 2025 15:26
@zibet27 zibet27 requested a review from Mr3zee July 15, 2025 08:20
@zibet27 zibet27 force-pushed the zibet27/ktor-client-webrtc-datachannels branch 2 times, most recently from fb6a1c4 to aae0b90 Compare July 16, 2025 16:08
@zibet27 zibet27 force-pushed the zibet27/ktor-client-webrtc-datachannels branch from aae0b90 to 4441aad Compare July 16, 2025 16:12
@zibet27 zibet27 requested a review from bjhham July 16, 2025 16:13
launch {
while (true) {
delay(config.statsRefreshRate)
events.emitStats(getStatistics())

Choose a reason for hiding this comment

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

If getStatistics() throws an exception, this coroutine will get cancelled silently, causing stats emission to stop, which might be confusing to some users. Consider catching the exception:

launch {
    while (true) {
        try {
            delay(config.statsRefreshRate)
            events.emitStats(getStatistics())
        } catch (e: CancellationException) {
            throw e // Respect coroutine cancellation
        } catch (e: Exception) {
            // Optional: log or emit an error event
        }
    }
}

Hope this helps 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi! In the new commit, I've updated WebRtcConnectionConfig so it accepts a custom coroutinesContext, which could be CoroutineExceptionHandler. Do you think we should provide a method to restart stats collection or do it automatically?

Choose a reason for hiding this comment

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

Great question! I think it depends on how resilient the stats collection is intended to be.

If it's meant to be long-running (e.g. like telemetry), I would lean toward restarting it automatically after non-cancellation exceptions, possibly logging or emitting an error event on the first failure. That way, users won't be surprised by stats stopping silently.

Alternatively, if we expect more advanced control or debugging scenarios, exposing a restartStatsCollection() method could be a good fallback.

Either way, I think you're on the right track by letting the coroutineContext carry the handler!

… custom `coroutineContext` in the rtc connection.
@zibet27 zibet27 requested a review from harrytmthy July 17, 2025 13:24
Copy link
Member

@Mr3zee Mr3zee left a comment

Choose a reason for hiding this comment

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

I like the new way here, thanks! Great job @zibet27

@zibet27 zibet27 force-pushed the zibet27/ktor-client-webrtc-datachannels branch from 064e153 to a91a285 Compare July 18, 2025 17:41
@zibet27 zibet27 merged commit 77956ec into zibet27/ktor-client-webrtc-android Jul 28, 2025
14 of 18 checks passed
@zibet27 zibet27 deleted the zibet27/ktor-client-webrtc-datachannels branch July 28, 2025 13:50
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.

6 participants