[Android 9.0.3] Enabling LLVM leads to incorrect SkiaSharp drawing behavior in some cases

Open
#114,822 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
28/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
android, csharp

Research direction

Start with the GnollHackMAUIEasyBuild reproduction repository and follow its Android Release build instructions. Reproduce the drawing failure with EnableLLVM enabled and AndroidEnableProfiledAot disabled, then compare it with LLVM disabled and profiled AOT enabled. Done means the radial-transparency drawing works correctly in the reported configuration or the runtime cause is isolated with a minimal reproduction.

Written by the indexing model from the issue text.

Description

area-Codegen-LLVM-mono
Description

In my game GnollHack, I have a specialized drawing function called DrawTileWithRadialTransparency that uses SkiaSharp to draw radial transparency for a bitmap. The function works always (on all platforms and in both Xamarin and MAUI), except for MAUI in Android in release mode when EnableLLVM is set to true and AndroidEnableProfileAot set to false, in which case it either does not draw anything or draws something in the wrong place with a wrong size. This seems to be some sort of an LLVM code generation bug, as the behavior makes otherwise little sense (it feels like the program does not do what is instructed in the code). Not sure why the problems occur just with this function, although it is a bit more complicated than the other ones. If I comment some parts of the code out (e.g. the unsafe block) or add something, the function most often still does not work as intended.

Reproduction Steps
  1. Clone the reproduction repository at https://github.com/hyvanmielenpelit/GnollHackMAUIEasyBuild
  2. Open GnollHackM solution
  3. Build it for Android in Release configuration according to instructions in the repository
  4. Note that EnableLLVM is on.
  5. Start the app on your Android device
  6. Press Settings button and switch Developer Mode on in System section, then press Close
  7. Switch on Wizard Mode
  8. Press Play Game, create a character and start playing
  9. Press More Commands button on bottom right corner, and scroll then left to Wizard Mode Commands
  10. Select Genesis and type yellow light
  11. A yellow light monster appears, but it has no graphics
  12. Quit the game and exit app
  13. Switch EnableLLVM to off and AndroidEnableProfiledAot to true.
  14. Go to step 3. In step 11, note that the yellow light has now graphics.
Expected behavior

Radial transparency function works with Android Release mode with EnableLLVM = true just like in every other case.

Actual behavior

The drawn picture either is not drawn or is drawn in the wrong position with the wrong size.

Regression?

Not sure. This is an LLVM problem.

Known Workarounds

None. Cannot use LLVM if I want to use the function in question.

Configuration

.NET 9.0.3, .NET MAUI 9.0.50, SkiaSharp 3.116.1
Android 15, ARM64

Other information

No response

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

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.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.