dotnet / dotnet/runtime

crossgen2 `--inputbubble` borks on interface property, `EntryPointNotFoundException`, but TC fixes it later

Open
#132,531 5 comments 0 reactions 1 assignee Claimed by @jtschuster View on GitHub
area-ReadyToRun
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Description

I'm crossgen-ing Paint.NET with `--inputbubble`, and I'm getting this exception from one of my rendering kernels. It happens when rendering tiles for the app's canvas; specifically when the zoom level is 50% or less, which is when tiles have mipmaps generated and must go through a scaling process.

NOTE: **Binary available on request. Repository access also available for MSFT employees (pre-approved).** @EgorBo has experience here.

```
System.EntryPointNotFoundException: Entry point was not found.
at PhotoSauce.MagicScaler.IPixelSource.get_Format()
at PhotoSauce.MagicScaler.PixelSourceExtensions.PixelSourceFromIPixelSource..ctor(IPixelSource)
at PhotoSauce.MagicScaler.PixelSourceExtensions.AsPixelSource(IPixelSource)
at PhotoSauce.MagicScaler.Experimental.TransformFactory.CreateScaleTransform(IPixelSource, Int32, Int32, InterpolationSettings )
at PaintDotNet.Canvas.TileCacheRenderer.MagicScalePixels(IBitmapSource`1 sourcePxyzw128FL, SizeInt32 dstSize) in D:\src\pdn\src2\PaintDotNet\Canvas\TileCacheRenderer.cs:line 179
at PaintDotNet.Canvas.TileCacheRenderer.CreateTileBitmap[TCancellationToken](RectInt32 sourceRect, SizeInt32 dstSize, TCancellationToken& cancelToken) in D:\src\pdn\src2\PaintDotNet\Canvas\TileCacheRenderer.cs:line 121
at PaintDotNet.Canvas.DocumentCanvasTileCache.RenderTileWorkItemImpl(Point2Int32 tileOffset) in D:\src\pdn\src2\PaintDotNet\Canvas\DocumentCanvasTileCache.cs:line 867
```

PhotoSauce.MagicScaler is @saucecontrol 's library that I use for things like bitmap scaling and color management.

I am trimming this particular DLL, but the `IPixelSource` interface and `IPixelSource.Format` property are definitely still there in the DLL as per inspection with ILSpy. Also, the error does not go away if I skip the trimming process.

If I `set DOTNET_ReadyToRun=0`: works fine
If I build without `--inputbubble`: works fine

And here's something I found funny: if I continue to perform actions which exercise this code path, it eventually starts working fine (see repro steps below). I imagine this is due to Tiered Compilation promoting this code from the crossgen'd AVX2 code to tier 2 AVX512 code.

### Reproduction Steps

1. Boot up a build of Paint.NET 5.2 alpha that is compiled for .NET 11. This needs to be a packaged build that has been fully crossgen'd, etc.

Image

2. Set the canvas zoom level to 50% or less (press Ctrl and Minus a few times). You'll see the canvas fill up with hard-to-read exception text. **This is the error.** (Yes, this is kind of a weird way to report exceptions in the canvas rendering code. I decided a long time ago it was preferable to crashing the app because I had some tiny little bug in one of the tools or its rendering code :) )

Image

3. Start scribbling on the canvas using the paintbrush tool (which is selected by default). After a few seconds, the error tiles will start going away and be replaced with the scribbles. **This is the Tiered Compilation promotion to working codegen.**

Image

### Expected behavior

No exceptions/errors.

### Actual behavior

Exceptions and errors as described in the repro steps, and then they go away once Tiered Compilation kicks in and promotes the code that's failing. (TC kicking in is my hypothesis, mind you, I have not fully verified the mechanism for this "healing".)

### Regression?

Yes. Worked fine in .NET 10.

It may have worked fine in a previous preview build of .NET 11, but that was a few months ago and I don't remember if I exercised this code path.

### Known Workarounds

1) Remove `--inputbubble` from crossgen2 command line

or 2) `set DOTNET_ReadyToRun=0` before launching the app

### Configuration

.NET 11.0.0-preview.7.26381.103 x64
Windows 11 Pro x64 (10.0.26200.9168)
AMD Ryzen 9 9950X3D2

### Other information

_No response_

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.