|Summary:||ImageRenderer, async void SetImage - Cannot catch exceptions|
|Product:||Forms||Reporter:||François M <francois.mouchati>|
|Severity:||normal||CC:||adrianknight89, david, ehart, jas, rui.marinho, v-nekha, v-sapaun|
|Tags:||iOS ac||Is this bug a regression?:||---|
|Last known good build:|
Description François M 2017-01-02 15:54:17 UTC
As SetImage is async void and not awaited, if it trows an error it cannot be caught and the app crashes. https://github.com/xamarin/Xamarin.Forms/blob/release-2.3.2/Xamarin.Forms.Platform.iOS/Renderers/ImageRenderer.cs#L106
Comment 1 adrianknight89 2017-02-25 00:55:34 UTC
If you do a quick search for "async void", you'll see that XF has this issue in many places (ignoring event handlers). Fixing them all will cause certain methods to be async even though they are not meant to be. For example, how would one handle GetCell() of iOS ImageCellRenderer? Also, SetImage() is handling TaskCanceledException so the user doesn't have to worry about it, but it wouldn't handle other types of exceptions. Since we're trying to load an image, I'm wondering if it makes sense to catch all exceptions and set uiimage = null;. What kind of error did you run into that crashed your app?
Comment 2 François M 2017-02-28 10:57:40 UTC
I wanted to catch error from LoadAsync which is called by SetImage. Since then, I found out I can do ExportImageSourceHandler and then implement my own LoadAsync.
Comment 3 E.Z. Hart [MSFT] 2017-03-30 22:43:47 UTC
Comment 4 Rui Marinho 2017-04-25 18:17:43 UTC
Should be fixed on 2.3.6-pre1
Comment 5 Neha Kharbade 2017-07-04 07:15:49 UTC
Hi Rui, Can you please help me for verifying the fix being applied in above bug. Any Steps to reproduce the bug would be great. Thanks in advance.
Comment 6 E.Z. Hart [MSFT] 2017-07-08 01:09:46 UTC
(In reply to Neha Kharbade from comment #5) > Hi Rui, > > Can you please help me for verifying the fix being applied in above bug. Any > Steps to reproduce the bug would be great. > > Thanks in advance. If you run the ControlGallery application, you can look at the test for issue 51173 and verify it using the instructions there.
Comment 7 Saurabh Paunikar 2017-07-12 12:26:01 UTC
Verified on xamarin.form version 188.8.131.526-pre6. I downloaded Xamarin.form master sample and run ControlGallery on android, iOS and UWP app. And followed the instruction given for test B51173. ScreenCast link : https://www.screencast.com/t/2GrP9QXLio