microsoft / microsoft/WindowsAppSDK

Perf opportunity, call RoGetActivationFactory much less often in xaml

Open
#6,043 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-UndockedRegFreeWinRT needs-triage
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

### Describe the bug

I traced every RoGetActivationFactory being made when Xaml starts up and I see a lot of calls that can be avoided if the factories were cached like they are in cppwinrt.

```cpp
// When launching the window and letting it paint, I observed
// 206 calls to RoGetActivationFactory or RoGetClassObject
// 68 unique names were passed.
// If cached 138 (206-68) will be saved.
// (206-68)/206 = ~67% calls will be cached.
```

I've got a drop-in replacement for the direct API use that implements caching and can share that with those interested in seeing what effect this has.

### Steps to reproduce the bug

I used the VS debugger ability to trace on method calls, setting breakpoints on these APIs. and launching the bare bones WinUI App sample template.

observe redundant calls

### Expected behavior

no redundancy, DRY.

### Screenshots

_No response_

### NuGet package version

None

### Packaging type

_No response_

### Windows version

_No response_

### IDE

_No response_

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing RoGetActivationFactory and RoGetClassObject in the XAML startup path, using the VS debugger and the bare-bones WinUI App sample described in the issue. Compare the observed calls with the 68 unique names and determine whether caching is safe; done means redundant factory or class-object calls are avoided without changing startup behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.