Skip to content

Offload DH key exchange crypto to background thread#30595

Open
shiel-pty wants to merge 1 commit intotelegramdesktop:devfrom
shiel-pty:fix/async-call-dh-crypto
Open

Offload DH key exchange crypto to background thread#30595
shiel-pty wants to merge 1 commit intotelegramdesktop:devfrom
shiel-pty:fix/async-call-dh-crypto

Conversation

@shiel-pty
Copy link
Copy Markdown

Summary

  • MTP::CreateModExp (a while(true) BigNum modular exponentiation loop) and MTP::CreateAuthKey were running synchronously on the main thread during call setup, freezing the UI for tens to hundreds of milliseconds
  • Moved all three call sites (start(), confirmAcceptedCall(), startConfirmedCall()) to crl::async with results posted back via crl::on_main
  • generateModExpFirst was removed as a separate method; its logic is now inlined in the start() async callback
  • startConfirmedCall signature changed to take MTPPhoneCall by value so it can be safely moved into the async lambda

Test plan

  • Outgoing call: initiate a call and verify the UI remains responsive while the call connects
  • Incoming call: answer an incoming call and verify no UI freeze during key exchange
  • Incoming call answered before DH config arrives: verify _answerAfterDhConfigReceived path still works correctly
  • Call hangup during key exchange: verify no crash when the call is ended while async is in flight

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 20, 2026

CLA assistant check
All committers have signed the CLA.

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