dotnet / dotnet/wpf

WriteableBitmap expensive to create on working thread

Open
#3,743 0 comments 0 reactions 0 assignees View on GitHub
.NET Framework Enhancement Requested
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity2.visualstudio.com/t/WriteableBitmap-expensive-to-create-on-w/625453)._

---

wpfapp5.zip Our application (WPF App .NET 4.6.2) grabs images from a camera and then process them. Working threads (Task) are doing this work. Receiving tasks need to create one or many WriteableBitmap objects. As this ones are DispatcherObjects, a Dispatcher is created (actually we create it - and a dummy WriteableBitmap object - when the thread starts to force the load of dependent resources) which at the end we shutdown to avoid leaks.

Problem: creation of first WriteableBitmap takes a lot, as well as shutting down the dispatcher when a WriteableBitmap is created on that thread.

Create dispatcher ~100 ms

Create WriteableBitmap ~600 ms

Shutdown dispatcher ~200 ms

Demo as attachment.

---
### Original Comments

#### Feedback Bot on 6/28/2019, 05:49 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

#### Feedback Bot on 8/8/2019, 09:34 AM:

We want to let you know that this problem will likely be closed in 60 days. We set priority based on severity, similar reports, and the overall impact on users and scenarios. We've also learned that reports without fresh activity could indicate that the problem isn't a problem anymore. One of our goals is to give you more transparency around these decisions as resolving every problem that gets reported isn't always possible. Your feedback is essential for helping us decide what needs the most attention, so please keep upvoting and commenting if you think that we need to make this a higher priority .
#### Marco Graf on 4/24/2020, 05:20 AM:

Hi Adrian

I tried your demo code with:
Microsoft Visual Studio Community 2019
Version 16.5.4
and got these results:

Create dispatcher: 0.3 - 0.44 ms
Create WriteableBitmap: 1.9 - 2.2 ms
Shutdown dispatcher: 3.2 - 3.6 ms

I hope you could resolve your problem in the meantime.

---
### Original Solutions
(no solutions)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.