Repository navigation
Refactor packet pixel tests - #603
JimBobSquarePants merged 18 commits into
Conversation
…le to be able to reproduce SixLabors#594. Note: the refactored better isolated tests do not produce the error
…le to be able to reproduce SixLabors#594. Note: the refactored better isolated tests do not produce the error
tocsoft
left a comment
There was a problem hiding this comment.
Thanks for this, it would be better if we had a file per pixel type instead of one huge class with unrelated tests.
|
@tocsoft yes indeed that would be better. I will change that. |
Codecov Report
@@ Coverage Diff @@
## master #603 +/- ##
==========================================
- Coverage 88.79% 88.53% -0.26%
==========================================
Files 854 872 +18
Lines 36207 36822 +615
Branches 2624 2620 -4
==========================================
+ Hits 32149 32602 +453
- Misses 3278 3444 +166
+ Partials 780 776 -4
Continue to review full report at Codecov.
|
|
@tocsoft travis seems to fail with: I guess this will be fixed if i change the travis file from dotnet: 2.1.300-rc1-008673 to dotnet: 2.1.300. I am not sure if that would fix it, i am not familiar with travis. Is it ok, if i give it a try? |
|
@brianpopow yeah feel free! We need to update our CI, so I'm curious what will be the outcome of this. |
|
seems to have worked :-) |
|
Different tests failing now |
|
@JimBobSquarePants @brianpopow we need to run those tests locally in 32 bit + older runtime, and analyse whether they need skipping, deleting, or a fix/workaround. Unfortunately I'm out of "ImageSharp office" at least for a week :( |
|
i thought i may have made a mistake during refactoring and double checked the original and the refactored version. As far as i can tell, the tests before and after refactoring should be the same. I did not notice this, because i always tested with netcoreapp2.0. This failing tests are not new. I checked the current master branch. The tests in Rgba64 is skipped in the PackedPixelTests, thats why it was not noticed. This time this issue seems to be at least reproducable in Debug and Release mode. |
|
@antonfirsov, @JimBobSquarePants: i think i have found the reason for the rgba64 tests failing. It happens when build with x86 and with net462/net471. In the Constructor of Rgba64 rounding is applied after multiplying the value with 65535. The test values for the B-Channel which was failing was 0.30f. Multiplying by 65535 leads to 19660,5. Rounding this should be 19660, but for net462/net471 this gives 19661. here is a simple reproduction, which mimics what happens in the RGBA Constructor: i think this is maybe an edge case for float not being able to represent decimal values accurately enough. |
|
We probably shouldn't be using |
|
@tocsoft my suggestion would be: changing the rgba64 constructor to use double instead of float. This would fix this issue. That does not mean there are no such edge cases with double too, but its at least much more unlikely. |
|
yes I think your right, that does sound like its probably the better fix. |
|
@brianpopow Nice detective work! 🥇 As long as we can interop with MonoGame's However, I would suggest changing the We should probably raise an issue with MonoGame also. |
|
I think the difference in the result is negligable, our test assertion shouldn't be that strict when dealing with floats. We need R, G, B, A properties on |
|
i must admit, i have rushed too fast to a conclusion yesterday. It is not actually a float issue. Here is a simple example to illustrate this This results in x86 to foo = 19660,5 Which explains why Round gives 19661 for that. There is a simple fix for that. Im just using MathF.Round from Sixlabors.Core. |
|
There is still one test failing If you look at the assertion: But if you look into the testcase, the expected value is: |
|
This issue with The best thing i have got is a workaround, which changes the assertion slightly: assert workaround This workaround seems to indicate that the |
|
@brianpopow with which framework did it fail? The older ones only? |
|
@antonfirsov net462/net471 at least. I suspect this issue only happens on x86, but that's just a guess. I could not test it on netcore2.0 x86 yet. |
|
@brianpopow definitely an untraceable JIT bug that got Your output suggests that the bug is probably in the code generated for the aggressively inlined Your test change is fine, TBH I do not want to spend more efforts on this kind of stuff - unless a user finds an actual bug related to this issue. |
|
Agreed. I think we should be safe to merge this and move on. @brianpopow Thanks for making such an awesome effort to refactor these tests and investigate issues. It must have been a chore of a job! |
Prerequisites
Description
This MR refactores The PacketPixelTests, so the tests are better isolated and do not test many things at once.
This was meant to help debugging the issue #594, but by splitting the tests up in smaller pieces, the issue no longer occurs. For the sake of being able to still reproduce this issue, i moved the original failing testcases (NormalizedByte4, NormalizedShort4, Short4) to a separate file (and they are skipped)