Bug 58048 - AspectFill behaves differently with Android.FastRenderers.ImageRenderer
Summary: AspectFill behaves differently with Android.FastRenderers.ImageRenderer
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.3.5
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-07-10 14:53 UTC by Matthew Richardson
Modified: 2017-10-05 18:17 UTC (History)
4 users (show)

See Also:
Tags: ac android image stacklayout isclippedtobounds fastrenderer
Is this bug a regression?: Yes
Last known good build: 2.3.4.247


Attachments
Screenshot showing XF 2.3.4 vs 2.3.5 (150.67 KB, image/jpeg)
2017-07-10 15:02 UTC, Matthew Richardson
Details
Repro Project XF 2.3.4 (115.93 KB, application/zip)
2017-07-10 15:03 UTC, Matthew Richardson
Details
Repro Project XF 2.3.5 (115.98 KB, application/zip)
2017-07-10 15:03 UTC, Matthew Richardson
Details

Description Matthew Richardson 2017-07-10 14:53:24 UTC
AspectFill behavior is different on XF 2.3.5 vs XF 2.3.4 when using an image in a nested view hierarchy.

Under certain conditions, the image is not cropped correctly to fit the bounds of its container and instead overlaps in the case of multiple images in a vertical layout.

See repro projects XF 2.3.4 vs XF 2.3.5 and screenshot showing difference.
Note: Using IsClippedToBounds="true" on a nested StackLayout in the demo project resolves the problem, but this was not required before XF 2.3.5 and don't want to assume this is a fix (may be a workaround).

Possibly without the parent ViewGroup with the new fast ImageRenderer on Android, the scale behavior has been changed.
Comment 1 Matthew Richardson 2017-07-10 15:02:15 UTC
Created attachment 23451 [details]
Screenshot showing XF 2.3.4 vs 2.3.5
Comment 2 Matthew Richardson 2017-07-10 15:03:18 UTC
Created attachment 23452 [details]
Repro Project XF 2.3.4

Good.
Comment 3 Matthew Richardson 2017-07-10 15:03:37 UTC
Created attachment 23453 [details]
Repro Project XF 2.3.5

Bad.
Comment 4 Jimmy [MSFT] 2017-07-10 21:14:00 UTC
I'm seeing the issue described using the attached repro projects and this does appear to be a regression in 2.3.5.

The images appear to be scaled correctly, they are just not being clipped. As mentioned, using IsClippedToBounds="true" on the inner StackLayout resolves the issue. I tested the same layout replacing the AbsoluteLayout with a RelativeLayout and the issue still occurred.

I also tested the old ImageRenderer and confirmed that the issues does _not_ occur in that case. So another workaround is to use the old renderer by exporting it like a custom renderer:

> [assembly:ExportRenderer(typeof(Xamarin.Forms.Image), typeof(Xamarin.Forms.Platform.Android.ImageRenderer))]


### Version Tests
2.3.6.117   BAD
2.3.5-pre6  BAD
2.3.4.247   GOOD
Comment 5 Matthew Richardson 2017-07-11 07:50:45 UTC
Jimmy - I wonder if the clipping behavior was happening implicitly due to the nesting of the image view inside a view group? So 'technically' now it is behaving as expected, but the behavior is not desirable.
Comment 6 Britton Beckham 2017-07-14 19:49:37 UTC
I was getting this same thing, but in a GridLayout. Shouldn't this be considered a breaking change if it is technically correct, even though it was wrong in the first place?

Note You need to log in before you can comment on or make changes to this bug.