Skip to content

Remove calls to Console.WriteLine to decrease app size #11405

@rolfbjarne

Description

@rolfbjarne

Description

It seems there are a few calls to Console.WriteLine in MAUI from:

  • Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
    • System.Boolean Microsoft.Maui.Handlers.WebViewHandler::LoadFile(System.String)
  • Microsoft.Maui.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
    • System.Boolean Microsoft.Maui.Authentication.WebAuthenticatorImplementation::OpenUrlCallback(System.Uri)

The whole Console machinery is quite expensive (size-wise), and removing the Console.WriteLine in these calls is likely to provide a significant size improvement for iOS apps.

For a sample test app here are some rough numbers:

  • System.Console.aotdata.arm64: 46.432 bytes
  • System.Console.dll: 9.728 bytes
  • Object files for System.Console.dll: 415.748 bytes
  • Total: 471.908 bytes

Note that this does not take into account any additional savings where API in other assemblies can be removed because System.Console was the only caller.

Public API Changes

N/A

Intended Use-Case

Size-optimized release builds.

Metadata

Metadata

Assignees

Labels

area-controls-webviewWebViewarea-essentialsEssentials: Device, Display, Connectivity, Secure Storage, Sensors, App Infofixed-in-8.0.0-preview.1.7762Look for this fix in 8.0.0-preview.1.7762!perf/generalThe issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)proposal/open

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions