Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Loading embedded font causes the app to crash on iOS after upgrade to Visual Studio 16.11.7 and 17.0.1, еmbedded images are not loaded anymore on iOS #14905

Closed
vg12345 opened this issue Nov 18, 2021 · 29 comments
Labels
a/fonts i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/iOS 🍎 s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. t/bug 🐛

Comments

@vg12345
Copy link

vg12345 commented Nov 18, 2021

Application that uses embedded font crashes on iOS

Reproduced on iOS 14.8.1
After upgrade of Visual Studio 2019 from 16.11.6 to 16.11.7
After upgrade of Visual Studio 2022 from 17.0.0 to 17.0.1

Xamarin Forms 5.0.0.2196 (same after upgrade to 5.0.0.2244)

Attached: App5.zip - the most simple application that reproduces the problem
App5.zip

Update:

  1. Embedded images are not loaded anymore on iOS!
  2. Looks like FileStream does not load images correctly too.

Attached: App6.zip. Reproduces the problem with embedded images on iOS. (Successfully loads on Android and UWP, but fails on iOS).
App6.zip
Important: you must build it and deploy to iPhone with Visual Studio 2022 version 17.0.1 to reproduce the problem!

Update:
Same problem on Visual Studio 2022 version 17.0.2

================================================================

  at <unknown> <0xffffffff>
  at ObjCRuntime.Messaging:void_objc_msgSend_IntPtr_UIntPtr <0x00022>
  at Foundation.NSMutableData:AppendBytes <0x00054>

  at Foundation.NSData:FromStream <0x0010c>
  at Xamarin.Forms.Platform.iOS.EmbeddedFontLoader:LoadFont <0x00016>
  at Xamarin.Forms.Internals.FontRegistrar:HasFont <0x0013e>
  at Xamarin.Forms.Platform.iOS.FontExtensions:CleanseFontName <0x0000c>
  at Xamarin.Forms.Platform.iOS.FontExtensions:_ToNativeFont <0x00124>
  at System.Func`4:invoke_TResult_T1_T2_T3 <0x000ae>
  at Xamarin.Forms.Platform.iOS.FontExtensions:ToNativeFont <0x000b4>

  at Xamarin.Forms.Platform.iOS.FontExtensions:ToNativeFont <0x0005c>
  at Xamarin.Forms.Platform.iOS.FontExtensions:ToUIFont <0x0000a>
  at Xamarin.Forms.Platform.iOS.LabelRenderer:UpdateFont <0x00082>
  at Xamarin.Forms.Platform.iOS.LabelRenderer:OnElementChanged <0x000d8>
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1:SetElement <0x002a2>
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1:Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement <0x00010>
  at Xamarin.Forms.Platform.iOS.Platform:CreateRenderer <0x00080>
  at Xamarin.Forms.Platform.iOS.VisualElementPackager:OnChildAdded <0x00084>

  at Xamarin.Forms.Platform.iOS.VisualElementPackager:Load <0x0005a>
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1:SetElement <0x00228>
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1:Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement <0x00010>
  at Xamarin.Forms.Platform.iOS.Platform:CreateRenderer <0x00080>
  at Xamarin.Forms.Platform.iOS.VisualElementPackager:OnChildAdded <0x00084>
  at Xamarin.Forms.Platform.iOS.VisualElementPackager:Load <0x0005a>
  at Xamarin.Forms.Platform.iOS.PageRenderer:ViewDidLoad <0x0010c>
  at System.Object:runtime_invoke_direct_void__this__ <0x0008e>
  at <unknown> <0xffffffff>
  at ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper <0x0001a>

  at UIKit.UIViewController:get_View <0x0006c>
  at Xamarin.Forms.Platform.iOS.PageRenderer:get_NativeView <0x00016>
  at Xamarin.Forms.Platform.iOS.PageRenderer:SetElement <0x00096>
  at Xamarin.Forms.Platform.iOS.Platform:CreateRenderer <0x00080>
  at Xamarin.Forms.Platform.iOS.Platform:AddChild <0x00052>
  at Xamarin.Forms.Platform.iOS.Platform:WillAppear <0x00086>
  at Xamarin.Forms.Platform.iOS.PlatformRenderer:ViewWillAppear <0x00040>
  at <Module>:runtime_invoke_direct_void__this___bool <0x0009e>
  at <unknown> <0xffffffff>
  at ObjCRuntime.Messaging:void_objc_msgSend <0x0001a>
  at UIKit.UIWindow:MakeKeyAndVisible <0x00038>
  at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate:SetMainPage <0x00022>
  at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate:FinishedLaunching <0x0006e>
  at App5.iOS.AppDelegate:FinishedLaunching <0x00032>
  at <Module>:runtime_invoke_direct_bool__this___UIApplication_NSDictionary <0x000c8>
  at <unknown> <0xffffffff>
  at UIKit.UIApplication:UIApplicationMain <0x000b8>
  at UIKit.UIApplication:Main <0x000b2>
  at App5.iOS.Application:Main <0x00012>
  at <Module>:runtime_invoke_direct_void_string[] <0x00092>
  at <unknown> <0xffffffff>
  at System.Reflection.RuntimeMethodInfo:InternalInvoke <0x00030>
  at System.Reflection.RuntimeMethodInfo:Invoke <0x000fc>
  at System.Reflection.MethodBase:Invoke <0x0001a>
  at Xamarin.iOS.HotRestart.Application:Run <0x001fa>
  at Xamarin.PreBuilt.iOS.Applications:Main <0x0005a>
  at <Module>:runtime_invoke_direct_void_string[] <0x00092>

=================================================================

The app has been terminated.

@vg12345 vg12345 added s/unverified New report that has yet to be verified t/bug 🐛 labels Nov 18, 2021
@angelru
Copy link

angelru commented Nov 19, 2021

Right now I can't debug apps on physical iPhone. I get that error and this one that I posted here.
https://developercommunity.visualstudio.com/t/iPhone-iOS-151-physical-debug/1572333

I need to test the camera and push notifications and I can't. Everything works fine in the emulator.

@jsuarezruiz jsuarezruiz added the i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often label Nov 19, 2021
@vg12345
Copy link
Author

vg12345 commented Nov 19, 2021

Update:

  1. Embedded images are not loaded anymore on iOS!
  2. Looks like FileStream does not load images correctly on iOS.

@royeagle
Copy link

I have the same issue with embedded images are not loaded on iOS. Please fix.

@andres-fg
Copy link

I can reproduce the same issue on an iPhone with iOS 15.0.2.

Using VS 2022 17.0.1

On the output window I get almost the same:

`

  at <unknown> <0xffffffff>
  at ObjCRuntime.Messaging:void_objc_msgSend_IntPtr_UIntPtr <0x00022>
  at Foundation.NSMutableData:AppendBytes <0x00054>
  at Foundation.NSData:FromStream <0x0010c>
  at Xamarin.Forms.Platform.iOS.EmbeddedFontLoader:LoadFont <0x00016>
  at Xamarin.Forms.Internals.FontRegistrar:HasFont <0x0013e>
  at Xamarin.Forms.Platform.iOS.FontExtensions:CleanseFontName <0x0000c>
  at Xamarin.Forms.Platform.iOS.FontExtensions:_ToNativeFont <0x00124>
  at System.Func`4:invoke_TResult_T1_T2_T3 <0x000ae>
  at Xamarin.Forms.Platform.iOS.FontExtensions:ToNativeFont <0x000b4>
  at Xamarin.Forms.Platform.iOS.FontExtensions:ToNativeFont <0x0005c>
  at Xamarin.Forms.Platform.iOS.FontExtensions:ToUIFont <0x0000a>
  at Xamarin.Forms.Platform.iOS.LabelRender

`

@David-Hartman-emclient
Copy link

I have a similar problem.


 at <unknown> <0xffffffff>
	  at ObjCRuntime.Messaging:void_objc_msgSend_IntPtr_UIntPtr <0x00022>
	  at Foundation.NSMutableData:AppendBytes <0x00054>
	  at Foundation.NSData:FromStream <0x0010c>
	  at <LoadImageAsync>d__1:MoveNext <0x00160>
	  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start <0x00052>
	  at Xamarin.Forms.Platform.iOS.StreamImagesourceHandler:LoadImageAsync <0x00062>
	  at <GetNativeImageAsync>d__10:MoveNext <0x000c4>
	  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start <0x00052>
	  at Xamarin.Forms.Platform.iOS.ImageElementManager:GetNativeImageAsync <0x00052>
	  at <SetImage>d__8:MoveNext <0x00530>
	  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start <0x00052>
	  at Xamarin.Forms.Platform.iOS.ImageElementManager:SetImage <0x0005c>
	  at <SetImage>d__6:MoveNext <0x00034>
	  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start <0x00052>
	  at Xamarin.Forms.Platform.iOS.ImageRenderer:SetImage <0x0004e>

@sblom
Copy link

sblom commented Nov 23, 2021

Happening here, too. Succeeds when I'm debugging an iPhone connected to my Mac, but fails when I'm debugging an iPhone directly connected to Windows.

@andres-fg
Copy link

Does anybody know a workaround for this?

@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Nov 25, 2021
@vg12345 vg12345 changed the title [Bug] Loading embedded font causes the app to crash on iOS after upgrade to Visual Studio 16.11.7 and 17.0.1 [Bug] Loading embedded font causes the app to crash on iOS after upgrade to Visual Studio 16.11.7 and 17.0.1, еmbedded images are not loaded anymore on iOS Nov 25, 2021
@jsuarezruiz
Copy link
Contributor

Tried https://github.com/xamarin/Xamarin.Forms/files/7563932/App5.zip in iPhone 8 with iOS 15.1 and iPad Mini with iPadOS 15.1 and cannot reproduce, could someone share a sample where reproduce the issue?

@jsuarezruiz jsuarezruiz added s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Nov 26, 2021
@vg12345
Copy link
Author

vg12345 commented Nov 26, 2021

Did you try to build and deploy it with the latest version of Visual Studio 2022 (17.0.1)?

@vg12345
Copy link
Author

vg12345 commented Nov 26, 2021

In addition:

Attached: App6.zip. Reproduces the problem with embedded images on iOS. (Successfully loads on Android and UWP, but fails on iOS).
Important: you must build it and deploy to iPhone with Visual Studio 2022 version 17.0.1 to reproduce the problem!

App6.zip

@EdwinLans
Copy link

Same problem here. After the update from Visual Studio 2022 17.0.0. to 17.0.1 the app crashes on my iOS device - Iphone. Same error as vg12345

@snice1981
Copy link

Exactly same problem here. After update of VS2019 and VS2022. Same code works well on ios simulator and also on another machine with older VS2019&VS2022

@vg12345
Copy link
Author

vg12345 commented Nov 30, 2021

Update:
Same problem on Visual Studio 2022 version 17.0.2

@vg12345
Copy link
Author

vg12345 commented Dec 1, 2021

Looks like more generic problem in Foundation.NSData:FromStream

https://developercommunity.visualstudio.com/t/xamarin-ios-in-visual-studio-2022-problem-with-com/1590471

@royeagle

This comment has been minimized.

@angelru
Copy link

angelru commented Dec 3, 2021

@jfversluis
Copy link
Member

Seems like a problem that is not related directly to Xamarin.Forms then. Please follow the linked support ticket, thanks :)

@vg12345
Copy link
Author

vg12345 commented Dec 15, 2021

Seems like nobody in Xamarin team wants even try to debug the attached application to ensure that the problem is not really in Xamarin.iOS platform.

@jfversluis
Copy link
Member

jfversluis commented Dec 15, 2021

Seems like nobody in Xamarin team wants even try to debug the attached application to ensure that the problem is not really in Xamarin.iOS platform.

There are a couple of responses that point out we did, not sure what you're trying to achieve here? Also, as the title suggests: it happens when you upgraded Visual Studio, not Xamarin.Forms. Isn't that a big hint that this is a problem in the IDE and not this SDK?

As much as I hate that we confuse customers with different portals to report issues in different products and all the problems that come with it, the reality is that when it's a problem with Visual Studio, the most effective way is to go through the Developer Community portal that is linked above.

@vg12345
Copy link
Author

vg12345 commented Dec 15, 2021

iOS applications crash if using embedded resources.
The crash happens in Xamarin Forms code.
Is it possible that recent IDE changes just showed some unknown bug in Xamarin?
The problem exists about a month. Did somebody investigate this on Xamarin side?

@jfversluis
Copy link
Member

jfversluis commented Dec 15, 2021

You say you are using Visual Studio 17.0.1 and are deploying to an iPhone. That means you are using what is called Hot Restart. The way Hot Restart works is that there is a prebuilt iOS app, that will dynamically load all of the Xamarin.Forms content, both from us on the SDK side as well as the code you write, inside of it. Including all the embedded resources and everything that is needed to run the app.

To be honest, I don't know how this piece of magic exactly works, I do know that we do not "own" the prebuilt iOS app that is provided as well as the infrastructure that is used to actually deploy and compile and do magic on you iOS device from Windows. So yes, you are using Xamarin.Forms, I totally understand how this must look like a Xamarin or Xamarin.Forms bug to you, but it most likely isn't.

iOS applications crash if using embedded resources.

If this is true, then the right place to report it would be the xamarin-macios repository since that is Xamarin.iOS, we build on top of that. But as far as I know Xamarin.iOS is not supported for Hot Restart and also your App6 is another Xamarin.Forms app not a pure Xamarin.iOS app

The crash happens in Xamarin Forms code.

How can that be if it also occurs with Xamarin.iOS projects? But seeing that App6 is also a Forms app, I guess the stack trace would show that indeed :)

Is it possible that recent IDE changes just showed some unknown bug in Xamarin?

Not likely because of how everything works when using Hot Restart, see above

The problem exists about a month. Did somebody investigate this on Xamarin side?

You can see that I linked a good number of issues on the Xamarin.Forms repo as well as from the Developer Community Portal, so yes people are busy looking into this.

I understand that you might be frustrated by this not working and it not being resolved quickly enough for you, but we're here to make things work. Not trying to close this as "not my problem", I hope that is clear from taking the time to respond to you in detail about how all this is going down.

Just to make sure one more time, I pulled down your App6 sample, ran it on a iPhone XS and an internal Visual Studio version 17.1.0 and I see that the image is not loading there, but with a different stack trace than yours. I'm installing VS2019 as we speak to see if that makes a difference. Do I understand correctly that the problem was not in 16.11.6 but the problem is in 16.11.7?

@vg12345
Copy link
Author

vg12345 commented Dec 15, 2021

Do I understand correctly that the problem was not in 16.11.6 but the problem is in 16.11.7?

The last versions without the problem are:
16.11.6 (VS 2019)
17.0.0 (VS 2022)

All later versions contain the problem.

Unfortunately, there is no any option to return to one of these "normal" versions for community edition.
The installations of older versions exist for professional and enterprise only

I see that the image is not loading there, but with a different stack trace than yours.

The stacks are different for fonts, images and probably other staff (I included the stack specifically for fonts - App5).
But the root of the problems seems to be somewhere here (this is common):

at <0xffffffff>
at ObjCRuntime.Messaging:void_objc_msgSend_IntPtr_UIntPtr <0x00022>
at Foundation.NSMutableData:AppendBytes <0x00054>
at Foundation.NSData:FromStream <0x0010c>

@jfversluis
Copy link
Member

Unfortunately I can't use VS2019 with iOS 15 it seems. Trying to see if I can somehow get my hands on Vs 17.0.0 to try.

But if this indeed has something to do with NSData.FromStream then this is still not on us. Again; not to say: not our problem, just so I know where to route this to so this can be resolved.

@dalexsoto does any of this mean something to you?

@vg12345
Copy link
Author

vg12345 commented Dec 15, 2021

Of cause, I have no idea which team is responsible for some specified part of code.
But. If there is very serios problem that prevents from people to develop on iOS with your platform, you can at least ensure that the problem is definitely in Foundation.NSData:FromStream (or maybe something else) and involve the relevant team inside Microsoft.
Did your team investigate this?
Can you approve that the problem is in Foundation.NSData:FromStream or reject this?
Not just waiting a month and close all relevant open issues as "not our problem"

@jfversluis
Copy link
Member

I'm not sure what you want from me here? That is exactly what I am trying to do right now? But my willingness to help is kind of draining if I keep getting negative comments like this to be honest. We're trying to achieve the same here.

@vg12345
Copy link
Author

vg12345 commented Dec 15, 2021

I'm not trying to offend you and my notes are not pointed personally to you, So, please, don't take it personally.
This is the issue about serious problem related to Xamarin development and it is reported to Xamarin development team.
I really appreciate your willingness to help but I think that fixing this problem is also the interest of Xamarin team and not just gesture of goodwill to some developer. But, as soon as this issue was closed without being solved, it's now really depends on a goodwill.

@jfversluis
Copy link
Member

I don't take it personally and I'm not offended no worries. However repeating the same thing over and over again is not very constructive while I am, I think, obviously trying to help you.

Also, the issue is not lost, else I wouldn't have closed it. As pointed out, the same issue has been reported through the Developer Community portal and is open there and I still believe that this is the right place for it as the cause of this bug does not originate in Xamarin.Forms.

I understand that from the "outside" it's hard to see which product is causing this, and frankly, as a customer you shouldn't even have to care, I get that. But routing this issue to the right product and team is the fastest way to get it resolved. Keeping it open here won't help anything.

@killer-frog
Copy link

I had this issue and found that I had some old mtouch arguments (--interpreter --optimize=experimental-xforms-product-type) still. Removed these and it worked fine.

@jfversluis
Copy link
Member

Oh that is great information, thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/fonts i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often p/iOS 🍎 s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. t/bug 🐛
Projects
None yet
Development

No branches or pull requests