Skip to content

Fix Behavior Differences in Unix System.Drawing.Common #22221

Closed

Description

@mellinoe

This is a tracking issue to mark failing tests against. I will fill this out with more details as I understand them.

Activity

  1. hughbe commented on Jun 10, 2017

    @hughbe
    Contributor

    What's the compat story for unix and GdIWindows? Are we looking for 1-1 compat even with bugs and edge cases?

  2. mellinoe commented on Jun 10, 2017

    @mellinoe
    ContributorAuthor

    I think it will probably be unreasonable to try to achieve "pixel perfect", 100% identical behavior for most of the library. I think we will need to be more lenient for edge case behavior and bugs in GDI+, but we can examine them case-by-case. I think once we get more tests online, behavior differences will become obvious. From what I've seen running your Icon tests on the Unix implementation, there are a lot of differences in edge-case and exception behavior, which are fixable by trying to re-use parts of the Windows implementation.

    @akoeplinger @marek-safar Any other thoughts to add?

  3. akoeplinger commented on Jun 10, 2017

    @akoeplinger
    Member

    I agree we'll have to try and see which edge-cases we run into and pixel perfect matching in all cases shouldn't be a goal (at least initially).

  4. hughbe commented on Jun 10, 2017

    @hughbe
    Contributor

    At least from looking at Icon.cs, a bunch of edge cases will be in exception types, disposal of objects and argument validation. This can be fixed by creating a PAL layer between the two implementations by starting to consolidate common code (preferring Windows where applicable)

  5. mellinoe commented on Jun 10, 2017

    @mellinoe
    ContributorAuthor

    @hughbe Yep, that was what I thought as well. I'm hopeful that a lot of the exception behavior can be unified in that way.

    Another good thing about Icon.cs is that it seems to be 90% managed code. There seem to be functional problems with some of the tests (lots of icons returning the wrong Width and Height), but that should be fixable from the C# code.

  6. mellinoe commented on Aug 8, 2017

    @mellinoe
    ContributorAuthor

    Here's some behavior differences I've discovered while trying to unify the Pen code, and other related types.

    Pen

    • Pen.get_CustomEndCap is emulated on Unix. There is no "get" accessor for this property in libgdiplus, so we return the last-known value that was set in managed code. This will most often be correct, but it is valid to set this prorpety through other means (PInvoke, native code, etc.), so the cached value is not guaranteed to be in sync with the native state of the object.
      NOTE: There are other places in the Windows System.Drawing code which make the same assumption, although it is wrong.
    • The get accessor of Pen.Color has different behavior on Unix when the value has never been set. Instead of throwing an ArgumentException, the code returns a "zero" color.

    CustomLineCap

    • libgdiplus does not implement GetCustomLineCapType. Currently this is only used to determine which subclass of CustomLineCap to return in its Clone method. I believe we can work around this limitation by just overriding the clone method in AdjustableArrowCap.
  7. mellinoe commented on Aug 31, 2017

    @mellinoe
    ContributorAuthor

    StringFormat

    SetDigitSubstitution does not work for some inputs on libgdiplus.

  8. mellinoe commented on Sep 11, 2017

    @mellinoe
    ContributorAuthor

    PrinterSettings

    Creating a PrinterSettings object with an invalid name causes a NullReferenceException.

  9. ViktorHofer commented on Mar 21, 2018

    @ViktorHofer
    Member

    @safern I think we should prioritize this item. Do you have plan to address the mentioned issues here or should I step in and help?

  10. safern commented on Mar 21, 2018

    @safern
    Member

    I've found plenty of tests disabled against this issue. I think we need to see which ones are still failing, try to consolidate all the exceptions between Windows and Unix and then all the libgdiplus related issues put them in one issue in corefx so that we can track them all, disable the tests against that issue and then open an issue in libgdiplus to get them fix and try to have a more stable cross library that compatibility is better.

  11. filipnavara commented on Mar 23, 2018

    @filipnavara
    Member

    @akoeplinger How feasible would it be to run the CoreFX System.Drawing.Common tests as part of the CI for libgdiplus?

  12. joshfree commented on Mar 29, 2018

    @joshfree
    Member

    Moving to the Future milestone

  13. filipnavara commented on Apr 2, 2018

    @filipnavara
    Member

    What's best way to update the [ActiveIssue(20884, TestPlatforms.AnyUnix)] tests if we fix an underlying bug in libgdiplus? Should we introduce a new ConditonalFact like GdiplusIsAvailable, but with test for a specific version?

  14. qmfrederik commented on Jun 26, 2019

    @qmfrederik
    Contributor

    I spent some time testing libgdiplus using the CoreFX test suite. I did that by building libgdiplus on Windows, and manually patching corefx code so that it would use libgdiplus.dll instead of gdiplus.dll.

    I currently see about ~75% of all drawing tests passing on libgdiplus on Windows.

    Here are a couple things I learned:

  15. transferred this issue fromdotnet/corefxon Jan 31, 2020
  16. added this to the Future milestone on Jan 31, 2020
  17. added
    untriaged
    on Feb 23, 2020
  18. removed
    untriaged
    on Jul 8, 2020
  19. teo-tsirpanis commented on Feb 1, 2022

    @teo-tsirpanis
    Contributor

    Since #64084 got merged, System.Drawing.Common does not work anymore on Unix. This issue should be closed.

  20. ghost locked as resolved and limited conversation to collaborators on Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Drawingbughelp wantedos-linuxtenet-compatibility

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions