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

VoiceNext stopped working due to change in protocol #508

Open
3 tasks done
Licho1 opened this issue Jun 10, 2024 · 9 comments
Open
3 tasks done

VoiceNext stopped working due to change in protocol #508

Licho1 opened this issue Jun 10, 2024 · 9 comments
Assignees
Labels
bug Something isn't working question Further information is requested
Milestone

Comments

@Licho1
Copy link
Contributor

Licho1 commented Jun 10, 2024

Summary

VoiceNext cannot receive messages

Reproduction Steps

[2024-06-10 16:42:45 +02:00] [303 /VoiceReceive] [Error] Exception occurred when decoding incoming audio data
System.ArgumentOutOfRangeException: CurrentSequenceWrapState was out of range
   at DisCatSharp.VoiceNext.Entities.AudioSender.GetTrueSequenceAfterWrapping(UInt16 originalSequence) in C:\work\Vocairos\DisCatSharp\DisCatSharp.VoiceNext\Entities\AudioSender.cs:line 141
   at DisCatSharp.VoiceNext.VoiceNextConnection.ProcessPacket(ReadOnlySpan`1 data, Memory`1& opus, Memory`1& pcm, List`1 pcmPackets, AudioSender& voiceSender, AudioFormat& outputFormat) in C:\work\Vocairos\DisCatSharp\DisCatSharp.VoiceNext\VoiceNextConnection.cs:line 694
   at DisCatSharp.VoiceNext.VoiceNextConnection.ProcessVoicePacket(Byte[] data) in C:\work\Vocairos\DisCatSharp\DisCatSharp.VoiceNext\VoiceNextConnection.cs:line 804

Minimal Reproducible Code

        guild = await disc.GetGuildAsync(serverId);
        var channels = await guild.GetChannelsAsync();
        voiceChannel = channels.First(x => x.Id == voiceChannelId);
        
        var voiceNext = disc.GetVoiceNext();
        audioConn = await voiceNext.ConnectAsync(voiceChannel);

        audioConn.UserJoined += (conn, args) =>
        {
            Console.WriteLine($"User {args.User.Username} joined");
            return Task.CompletedTask;
        };


        audioConn.UserSpeaking += (conn, args) =>
        {
            Console.WriteLine($"User {args.User.Username} speaking");
            return Task.CompletedTask;
        };


        audioConn.VoiceReceived += (conn, args) =>
        {
        };

Expected Results

In the past identical code worked

Actual Results

Exception occurs

System Information

Not relevant, windows 11

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

@Lulalaby
Copy link
Member

Lulalaby commented Jul 3, 2024

Does this still occur? Might be a problem with Discord. I'm not aware of any changes since we're still using the default voice gw version which is so old, it won't really be changed anyways, normally.

@Licho1
Copy link
Contributor Author

Licho1 commented Jul 3, 2024

Yes this problem still occurs. It should be fully replicable (happens 100% of time)

@Lulalaby
Copy link
Member

Lulalaby commented Jul 3, 2024

ah damn it
@TheXorog do you still run a version with vnext? Or do I have to put nyuw back to life

@Lulalaby Lulalaby added bug Something isn't working question Further information is requested labels Jul 3, 2024
@Lulalaby Lulalaby added this to the APIv10 milestone Jul 3, 2024
@TheXorog
Copy link
Member

TheXorog commented Jul 3, 2024

I don't but i could set it up test stuff with Makoto with pretty minimal effort (basically just adding vn and a few test commands)

@TheXorog
Copy link
Member

TheXorog commented Jul 3, 2024

Can confirm this happens with IncomingAudio enabled.

Tested with:

[SlashCommand("test", "Test.")]
public async Task Test(InteractionContext ctx, [Option("test", "test"), MinimumValue(1), MaximumValue(2000)] int number)
{
	try
	{
		var guild = ctx.Guild;
		var channels = await guild.GetChannelsAsync();
		var voiceChannel = channels.First(x => x.Id == 1036569241488474192ul);

		var voiceNext = ctx.Client.GetVoiceNext();
		var audioConn = await voiceNext.ConnectAsync(voiceChannel);

		audioConn.UserJoined += (conn, args) =>
		{
			Log.Debug("User {user} joined", args.User.Username);
			return Task.CompletedTask;
		};


		audioConn.UserSpeaking += (conn, args) =>
		{
			Log.Debug("User {user} speaking", args.User.Username);
			return Task.CompletedTask;
		};


		audioConn.VoiceReceived += (conn, args) =>
		{
			return Task.CompletedTask;
		};
	}
	catch (Exception ex)
	{
		Log.Error(ex, "Error");
	}
}

@Lulalaby I don't think we ever fixed incoming audio, did we?

@Licho1 For the time being, if you do not need incoming voice data you can disable that and no exception will be thrown anymore. If you do, you'll need to wait for us to fix it (or make a PR to fix it, if you'd like). I'll take a look at it today but i can't promise anything, i have basically no idea about VoiceNext.

@Licho1
Copy link
Contributor Author

Licho1 commented Jul 3, 2024

Thanks!
I do use incoming audio (for a talking AI cat), and it has worked fine for me in the past (since about this PR #396 )

So it seems that discord has changed something. I have no idea how this protocol works, is there some documentation for voice protocol? Or is it all reverse engineered?

@TheXorog
Copy link
Member

TheXorog commented Jul 3, 2024

The only thing i can tell from my testing is that the issue lies in AudioSender, some method that looks to be a workaround for out of order packets, i'm not really sure at all. Tried playing around with it earlier but got nowhere really. I'm not really experienced with this kind of stuff unfortunately, so that was to be expected (and neither do i have the motivation to actually try and learn it atm).

As for docs this seems to be the only docs. I'd assume you'd the same for receiving as sending just backwards.

We'll have to wait for Lala to fix it (or for me to sit my ass down and learn lol). We're gonna fix this one way or another, probably

@Lulalaby
Copy link
Member

@Licho1 dumb idea, but could you try 10.6.5-nightly-003 in a while (building right now) with the DisCatSharp.VoiceNext.Natives update

@Licho1
Copy link
Contributor Author

Licho1 commented Oct 3, 2024

I have forgotton to mention, it didn't fix it. Bug still persist in 10.6.6.-nightly-018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Development

No branches or pull requests

3 participants