-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] [iOS] Crash When the First Toolbar Item Has an Icon and a Second Item Gets Added #6387
Comments
It does seem to have something to do with the fact that at least one of the items has an icon. This line in the error:
Made me try to comment out the |
The first item must have an icon to trigger the exception. If the first item has not an icon, but the second one has, it works as expected without an exception. |
+1 to fix this. Anyone found a workaround? @jfversluis We use ImageSource.FromFile() for both toolbar items but it seems that it doesn't help. So it is related to how it is named in the title I guess. |
Additionally, we keep the references of toolbarItems in code behind, and we change the icons dynamically to represent the state of background sync and device connection. We add the try-catch code, but the exception can not be caught, it just crashes the app. So I would kindly ask for a bit more defensive programming, try-catch here and there in the framework, prevention of NPEs with ?. and as operator, here and there. Because we already stumbled upon several issues in xamarin framework where the uncaught exceptions in the framework completely crash our app and we can not do anything to prevent it, other than some time consuming hacks, if we are able to find them. |
Actually, by further investigation we think this crash is related to CachedImageRenderer.InitImageSourceHandler(); from FFImageLoading library and issue should potentially be opened there. |
Great find @brcinho keep us updated on further developments |
I had this crash as well using the shared resources in the Xamarin.Forms project:
|
Can confirm this is related to using FFImageLoading. See the bug in their repo: luberda-molinet/FFImageLoading#1460 |
I am not using FFImageLoafing for the icons, but I do have it in the
project as a dependency. Are you saying it’s intercepting the calls?
A comment in the bug report states “In addition, there are no problems when using IconImageSource for ContentPage or something else.”, isn’t that contradictory?
…On Monday, July 27, 2020, Fabian Schipp ***@***.***> wrote:
Can confirm this is related to using FFImageLoading. See the bug in their
repo: luberda-molinet/FFImageLoading#1460
<luberda-molinet/FFImageLoading#1460>
Though I am not sure where this bug originates.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6387 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOL6P6FMNZR3MM3K6HTMF2TR5V3XRANCNFSM4HSHWU4Q>
.
--
|
I know, but on my side it crashes 100% when I do the following:
|
But then it's not related to using FFImageLoading, rather than FFImageLoading also crashing
due to this.
…On Tue, Jul 28, 2020 at 7:52 AM Fabian Schipp ***@***.***> wrote:
I know, but on my side it crashes 100% when I do the following:
- use CachedImageRenderer.InitImageSourceHandler(); to initialise the
FFImageLoading
- use an IconImageSource for a ToolbarItem on a ContentPage
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6387 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOL6P6CSS4MGDG2PT5YSU73R5ZKQZANCNFSM4HSHWU4Q>
.
|
I have noticed that the crash happens 100% on the first time the menu is rendered on a clean install. Consecutive boots of the app don't show this issue. After it has crashed once, I can not reproduce the crash until I reinstall the app, after which it always happens once the first time it renders the menu. Please help. |
I also ran into this issue yesterday and, to my surprise, found that nobody seems to have reported this issue to the FFImageLoading-team yet, notwithstanding the fact that this clearly seems to be an issue to do with that library. That is, the line causing issues is Since this line appears to only enable FFImageLoading on image types no directly related to FFImageLoading itself, an easy work-around would be to consistently use FFImageLoading's own controls throughout your app, and disable the aforementioned line in your Another work-around that allows you to leave the FFImageLoading's initialization in place is to simply put a delay on insertion of your toolbar item. If inserted a while after the page has been rendered, the app doesn't crash either. As such, it may be enough to simply insert your toolbar item on the page's To get things moving with FFImageLoading, I filed a bug report there. |
Also happens with Xamarin.Forms.Nuke. I guess it happens if you use a custom Image Source Handler and has nothing to do with FFImageLoading specifically. |
This seems to be definitely a crash in Xamarin.Forms Apparently the default implementation by Xamarin.Forms (https://github.com/xamarin/Xamarin.Forms/blob/f35ae07a0a8471d255f7a1ebdd51499e10e0a4cb/Xamarin.Forms.Platform.iOS/Renderers/ImageRenderer.cs) is not really async, it returns without awaiting - therefor there is no time for the control to get disposed. If the implementation, either by FFImageLoading or Xamarin.Forms.Nuke or any other implementation is really async, the toolbar control can be disposed in the meantime and then the crash happens. @samhouts This seems to be definitely a crash bug in Xamarin.Forms and is not related to either library. I can also imagine other code parts, where there is the same bug. Before assigning Image of PrimaryToolbarItem or SecondaryToolbarItem, there has to be a check, if the control has been disposed. (Again, this has to be everywhere, where there is Code similar to |
@acuntex My original issue is definitely related to Xamarin.Forms. It's so minimalistic that it can't be anything else. |
@abduelhamit Absolutely. Same would happen if you would use a remote image as toolbar item. @samhouts Any update? This is a crash bug. |
@PureWeen When will 5.0.1 come out? Thank you. |
Any updates on this. It's been open for a long time and is a system crashing bug. I can get this to occur every time by putting the application in background and then rendering the toolbar Does anyone have good workarounds to keep this from crashing app? |
I never did and resorted to removing toolbar images. @jfversluis any chance of fixing this crash in a service release? Thanks! |
I've found that in my situation a workaround was to recreate the ToolbarItem each time the toolbar is reloaded. Previously, I was using ToolbarItem objects in memory and based on certain conditions would add/remove buttons on navigation. This is done via a Behavior attached to the page. I modified so after calling ToolbarItems.Clear() instead of using the existing objects I clone the ToolbarItems. So far this seems to be working for me
|
ANY UPDATES???? NEWS??? HELLLOOO??? |
@scriptBoris I understand that you might feel some frustration, I also hope you understand that this will not make us move any faster. We're working as fast as we can. See #14205 for more context. |
@Tommigun1980 thanks for tagging this! Adding it to our list |
Thank you for working so hard on fixing the issues! Regarding this crash issue, it only happens for me when running my app on a physical device, and only the first time after an install (when the toolbar is rendered). So if you can’t reproduce please try those steps. |
Possible hack: Create some marker to mark ImageResource which we are using for toobar item:
Assign this marker when you create ToolbarItem:
Somewhere in iOS project
|
The issue will be fixed by #14749 and we will include it in SR7. |
If you want you could grab the NuGet as described here and let us know if this fixes this issue? That will greatly speed up the review process. Besides verifying if this particular issue is fixed also be sure to check other scenarios in the same area to make sure that this fix doesn't accidentally has side-effects 🙂 Thanks! |
Has this issue returned in 5.0.0.2545? It looks like it! @jfversluis @jsuarezruiz
|
Steps to Reproduce
The relevant code:
Expected Behavior
No crashs.
Actual Behavior
Basic Information
Reproduction Link
https://drive.google.com/file/d/14VnLQbRIGfDIYxrX6IKK5Bd3cIglrk3I/view?usp=sharing
The text was updated successfully, but these errors were encountered: