Skip to content

perf: Avoid I/O on main thread#153

Merged
LouisCAD merged 2 commits intomainfrom
avoid-io-on-main-thread
Apr 30, 2026
Merged

perf: Avoid I/O on main thread#153
LouisCAD merged 2 commits intomainfrom
avoid-io-on-main-thread

Conversation

@LouisCAD
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings April 30, 2026 13:21
@LouisCAD LouisCAD enabled auto-merge April 30, 2026 13:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to reduce main-thread blocking by deferring HttpClient creation and moving it onto an IO dispatcher, then plumbing the needed coroutine scope through the library’s facade.

Changes:

  • Refactor ApiClientProvider to lazily create the Ktor HttpClient via a deferred running on Dispatchers.IO.
  • Update AuthenticatorRequest to accept an HttpClient provider (suspend () -> HttpClient) and invoke it per request.
  • Pass a CoroutineScope from AuthenticatorFacade into ApiClientProvider, and eagerly initialize AppSettingsDatabase in MainApplication as a StrictMode workaround.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
multiplatform-lib/src/commonMain/kotlin/internal/requests/AuthenticatorRequest.kt Switches from a concrete HttpClient to a suspend provider and updates request calls accordingly.
multiplatform-lib/src/commonMain/kotlin/internal/network/ApiClientProvider.kt Introduces lazy async HttpClient creation on Dispatchers.IO and exposes it as a suspend provider.
multiplatform-lib/src/commonMain/kotlin/AuthenticatorFacade.kt Wires a CoroutineScope into ApiClientProvider construction.
app/src/main/kotlin/com/infomaniak/auth/MainApplication.kt Adds an injected AppSettingsDatabase field to force eager DB initialization prior to enabling StrictMode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/main/kotlin/com/infomaniak/auth/MainApplication.kt
@LouisCAD LouisCAD force-pushed the avoid-io-on-main-thread branch from 1b2a124 to 8ecec02 Compare April 30, 2026 15:09
@sonarqubecloud
Copy link
Copy Markdown

@LouisCAD LouisCAD merged commit e2a7966 into main Apr 30, 2026
9 checks passed
@LouisCAD LouisCAD deleted the avoid-io-on-main-thread branch April 30, 2026 15:11
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.

3 participants