Skip to content

Correctly free resources in Uno Platform's SKXamlCanvas#3431

Open
MartinZikmund wants to merge 3 commits intomono:mainfrom
MartinZikmund:dev/mazi/free-bitmap
Open

Correctly free resources in Uno Platform's SKXamlCanvas#3431
MartinZikmund wants to merge 3 commits intomono:mainfrom
MartinZikmund:dev/mazi/free-bitmap

Conversation

@MartinZikmund
Copy link
Contributor

Description of Change

Freeing pixels field in Uno Platform's SKXamlCanvas should not free bitmap and vice versa.

Bugs Fixed

API Changes

None.

Behavioral Changes

Code no longer throws in case the canvas size changes.

Required skia PR

None.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Merged related skia PRs
  • Changes adhere to coding standard
  • Updated documentation

Copy link
Contributor

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

Fixes resource lifetime handling in Uno Platform’s SKXamlCanvas so reallocating the pixel buffer (eg. during resize) no longer invalidates the WriteableBitmap, preventing NullReferenceExceptions and separating pixel/bitmap cleanup.

Changes:

  • Update DoUnloaded() to free both the WriteableBitmap and the pinned pixel buffer.
  • Rework CreateBitmap() to (re)allocate/free pixels independently of bitmap, avoiding resize-time NREs.
  • Split cleanup into FreePixels() and FreeBitmap().

@mattleibow
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

mattleibow added a commit that referenced this pull request Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[BUG] Resources are not freed correctly in Uno Platform's SKXamlCanvas

3 participants