Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crash on launch #9282

Closed
vsfeedback opened this issue Jul 8, 2020 · 38 comments
Closed

App crash on launch #9282

vsfeedback opened this issue Jul 8, 2020 · 38 comments
Labels
iOS Issues affecting Xamarin.iOS need-info Waiting for more information before the bug can be investigated
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


With the latest Xamarin.Forms 4.7 in combination with the latest VS for Mac Stable version, my app always crashes at launch (no other change involved, it works with Forms 4.6 without any problem and did work with 4.7 as well before the latest update). This crash only happens on Release Build while Debug runs fine.

The only message I get when trying to run this app in release is the following:
dyld: Library not loaded: @rpath/Mono.framework/Mono
Referenced from: /Users/sebastian/Library/Developer/CoreSimulator/Devices/F9AECBD1-5630-4236-99BF-DD72415098E2/data/Containers/Bundle/Application/BBC8B3D3-6D9C-4968-A5C3-CD0766F3AF8C/MyApp.iOS.app/BreathCompanion.iOS
Reason: image not found


Original Comments

Visual Studio Feedback System on 7/5/2020, 11:03 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

@jsuarezruiz
Copy link

Could be related with Clip and fixed by xamarin/Xamarin.Forms#11280?

@Sebastian1989101
Copy link

As mentioned in the bugreport of VS for Mac: In my case it seems like the App Bundle shrinks by 13.3MB alone from the Xamarin.Forms 4.6 to 4.7 upgrade. So I guess something did get removed. This is btw. a Mapsui.Forms project so SkiaSharp is also involved.

@PureWeen
Copy link

PureWeen commented Jul 9, 2020

@Sebastian1989101 if you create a blank forms app and use Mapsui.Forms there do you see the same exception?

@Sebastian1989101
Copy link

@PureWeen I would have to setup it so deep that I can push a TestFlight version. Would take some time to setup such a project.

Is there a way to compare a working app bundle archive to a broken one? So I would know where the changes are. As said, 13.3MB smaller - I'm pretty sure something is getting linked out.

@PureWeen
Copy link

PureWeen commented Jul 9, 2020

So when you build it as release in vs it works fine but it fails when it's released from TestFlight?

@Sebastian1989101
Copy link

@PureWeen Seems like this is only happen on a TestFlight build. At least I'm currently not able to reproduce it when running a release build in the simulator. Which does not mean that this is something we can work with.

@PureWeen
Copy link

PureWeen commented Jul 9, 2020

If you deploy to a physical device locally does it crash?

@Sebastian1989101
Copy link

@PureWeen Seems like running on a device with release build does also fail while a debug build runs fine.

@PureWeen
Copy link

PureWeen commented Jul 9, 2020

If you enable full linking with the simulator does it crash?

if you add something likee this to app delegate does it fix the crash?

        public void Thing()
        {
            throw new Exception(typeof(Mapsui.UI.Forms.Callout).Name);
        }

@Sebastian1989101
Copy link

@PureWeen setting it to Link All results in crashing. But my release builds are also only set to Link SDK so I tried this and it works in Debug on the Simulator. However, the build version for the AppStore and TestFlight is still smaller than expected with Forms 4.7 compared to 4.6 after the last VS for Mac update (before this update, 4.7 was also fine).

I don't think that this is a problem of Mapsui or SkiaSharp just because it happens in this project. And yes, 4.7 seems to work in other projects and I have no idea why. It looks like something gets linked out on the Link SDK setting but I have no idea why and what.

This are the configs for our latest TestFlight beta releases of this app:
Xamarin.Forms 4.6 and Previous Visual Studio for Mac Version: Works
Xamarin.Forms 4.7 and Previous Visual Studio for Mac Version: Works
Xamarin.Forms 4.7 and Latest stable Visual Studio for Mac Version: Crashes
Xamarin.Forms 4.6 and Latest stable Visual Studio for Mac Version: Works

I don't know which version of Visual Studio for Mac I had installed in May but this is the current installation:

Visual Studio Enterprise 2019 for Mac
Version 8.6.5 (build 23)
Installation UUID: 4f5a765e-ea38-4825-804a-0b1471e55be2
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

	Package version: 610000104

Mono Framework MDK
Runtime:
	Mono 6.10.0.104 (2019-12/5d03a6fe116) (64-bit)
	Package version: 610000104

Roslyn (Language Service)
3.6.0-3.20210.9+4eafdcb1bcbd8d3573f2ba6065e56d9b9ce4f8a3

NuGet
Version: 5.6.0.6591

.NET Core SDK
SDK: /usr/local/share/dotnet/sdk/3.1.301/Sdks
SDK Versions:
	3.1.301
	3.1.300
	3.1.202
	3.1.200
	3.1.102
	3.1.101
	3.1.100
	3.0.101
	3.0.100
	2.1.701
	2.1.700
	2.1.505
	2.1.504
	2.1.503
	2.1.302
	2.1.301
	2.1.4
	2.0.0
	1.0.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin/Sdks

.NET Core Runtime
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	3.1.5
	3.1.4
	3.1.2
	3.1.1
	3.1.0
	3.0.1
	3.0.0
	2.1.19
	2.1.18
	2.1.17
	2.1.16
	2.1.15
	2.1.14
	2.1.13
	2.1.12
	2.1.11
	2.1.9
	2.1.8
	2.1.7
	2.1.2
	2.1.1
	2.0.5
	2.0.0
	1.1.2
	1.0.5

Xamarin.Profiler
Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Xamarin Designer
Version: 16.6.0.329
Hash: d4f8bcd13
Branch: remotes/origin/d16-6
Build date: 2020-04-24 02:16:02 UTC

Xamarin.Android
Version: 10.3.1.4 (Visual Studio Enterprise)
Commit: xamarin-android/d16-6/3a10de9
Android SDK: /Users/sebastian/Library/Android/sdk
	Supported Android versions:
		4.4 (API level 19)
		5.1 (API level 22)
		6.0 (API level 23)
		7.0 (API level 24)
		7.1 (API level 25)
		8.0 (API level 26)
		8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.6
SDK Build Tools Version: 28.0.3

Build Information: 
Mono: 165f4b0
Java.Interop: xamarin/java.interop/d16-6@2cab35c
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.31.1@49232bc
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-6@bfb66f3

Microsoft OpenJDK for Mobile
Java SDK: /Users/sebastian/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 16.6.0.50
Hash: 5901879
Branch: remotes/origin/d16-6
Build date: 2020-06-10 22:42:50 UTC

Android Device Manager
Version: 16.6.0.96
Hash: 6e8b80b
Branch: remotes/origin/d16-6
Build date: 2020-06-10 22:43:28 UTC

Apple Developer Tools
Xcode 11.5 (16139)
Build 11E608c

Xamarin.Mac
Version: 6.18.2.1 (Visual Studio Enterprise)
Hash: 29c4ea731
Branch: d16-6
Build date: 2020-05-26 17:03:04-0400

Xamarin.iOS
Version: 13.18.2.1 (Visual Studio Enterprise)
Hash: 29c4ea731
Branch: d16-6
Build date: 2020-05-26 17:03:05-0400

Build Information
Release ID: 806050023
Git revision: 5289d413b99fddfc20b4ecf3e445ccb822213427
Build date: 2020-06-18 12:08:30-04
Build branch: release-8.6
Xamarin extensions: 5289d413b99fddfc20b4ecf3e445ccb822213427

Operating System
Mac OS X 10.15.5
Darwin 19.5.0 Darwin Kernel Version 19.5.0
    Tue May 26 20:41:44 PDT 2020
    root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

@Sebastian1989101
Copy link

Uploading a version without linking works btw. but the result is more than 100mb larger than usual.

@PureWeen
Copy link

PureWeen commented Jul 13, 2020

it works in Debug on the Simulator

When you set it to link all, debug, and push to device does it work?

@Sebastian1989101
Copy link

@PureWeen no because link all did never worked for me. Thats why I only used Link SDK instead. Link all is also crashing in the simulator already only way to run it is Link SDK or None for the Simulator and only None for real devices with the current version.

@PureWeen
Copy link

if you do link all in debug mode does it reveal a more useful exception

@Sebastian1989101
Copy link

I have no idea why you want a Link all result because as I already told you, this will fail for sure. But here is the log from Link all:

2020-07-13 17:22:26.165154+0200 BreathCompanion.iOS[33889:291042] 2020-07-13 17:22:26 [TRACE] (MvvmCross.Core.MvxSetup) Setup: Primary start
2020-07-13 17:22:26.165459+0200 BreathCompanion.iOS[33889:291042] 2020-07-13 17:22:26 [TRACE] (MvvmCross.Core.MvxSetup) Setup: FirstChance start
2020-07-13 17:22:26.278873+0200 BreathCompanion.iOS[33889:291042] 2020-07-13 17:22:26 [TRACE] (MvvmCross.Core.MvxSetup) Setup: Platform services
2020-07-13 17:22:26.279112+0200 BreathCompanion.iOS[33889:291042] 2020-07-13 17:22:26 [TRACE] (MvvmCross.Core.MvxSetup) Setup: MvvmCross settings start
2020-07-13 17:22:32.671522+0200 BreathCompanion.iOS[33889:291042] Unhandled managed exception: Failed to find constructor for type MvvmCross.Core.MvxSettings (MvvmCross.Exceptions.MvxIoCResolveException)
  at MvvmCross.IoC.MvxIoCContainer.IoCConstruct (System.Type type, System.Collections.Generic.IDictionary`2[TKey,TValue] arguments) [0x00011] in D:\a\1\s\MvvmCross\IoC\MvxIoCContainer.cs:413 
  at MvvmCross.IoC.MvxIoCContainer.IoCConstruct (System.Type type) [0x00000] in D:\a\1\s\MvvmCross\IoC\MvxIoCContainer.cs:363 
  at MvvmCross.IoC.MvxIoCContainer.IoCConstruct[T] () [0x00000] in D:\a\1\s\MvvmCross\IoC\MvxIoCContainer.cs:369 
  at MvvmCross.IoC.MvxIoCProvider.IoCConstruct[T] () [0x00000] in D:\a\1\s\MvvmCross\IoC\MvxIoCProvider.cs:144 
  at MvvmCross.IoC.MvxIoCContainerExtensions+<>c__DisplayClass14_0`2[TInterface,TType].<LazyConstructAndRegisterSingleton>b__0 () [0x00000] in D:\a\1\s\MvvmCross\IoC\MvxIoCContainerExtensions.cs:172 
  at MvvmCross.IoC.MvxIoCContainer+ConstructingSingletonResolver.Resolve () [0x00028] in D:\a\1\s\MvvmCross\IoC\MvxIoCContainer.cs:152 
  at MvvmCross.IoC.MvxIoCContainer.InternalTryResolve (System.Type type, MvvmCross.IoC.MvxIoCContainer+IResolver resolver, System.Object& resolved) [0x0005f] in D:\a\1\s\MvvmCross\IoC\MvxIoCContainer.cs:588 
  at MvvmCross.IoC.MvxIoCContainer.InternalTryResolve (System.Type type, System.Nullable`1[T] requiredResolverType, System.Object& resolved) [0x00042] in D:\a\1\s\MvvmCross\IoC\MvxIoCContainer.cs:526 
  at MvvmCross.IoC.MvxIoCContainer.InternalTryResolve (System.Type type, System.Object& resolved) [0x00000] in D:\a\1\s\MvvmCross\IoC\MvxIoCContainer.cs:503 
  at MvvmCross.IoC.MvxIoCContainer.Resolve (System.Type t) [0x00011] in D:\a\1\s\MvvmCross\IoC\MvxIoCContainer.cs:250 
  at MvvmCross.IoC.MvxIoCContainer.Resolve[T] () [0x00000] in D:\a\1\s\MvvmCross\IoC\MvxIoCContainer.cs:242 
  at MvvmCross.IoC.MvxIoCProvider.Resolve[T] () [0x00000] in D:\a\1\s\MvvmCross\IoC\MvxIoCProvider.cs:66 
  at MvvmCross.Core.MvxSetup.CreateSettings () [0x00000] in D:\a\1\s\MvvmCross\Core\MvxSetup.cs:166 
  at MvvmCross.Core.MvxSetup.InitializeSettings () [0x00000] in D:\a\1\s\MvvmCross\Core\MvxSetup.cs:160 
  at MvvmCross.Core.MvxSetup.InitializePrimary () [0x00081] in D:\a\1\s\MvvmCross\Core\MvxSetup.cs:86 
  at MvvmCross.Core.MvxSetupSingleton.StartSetupInitialization () [0x0000a] in D:\a\1\s\MvvmCross\Core\MvxSetupSingleton.cs:181 
  at MvvmCross.Core.MvxSetupSingleton.EnsureInitialized () [0x00017] in D:\a\1\s\MvvmCross\Core\MvxSetupSingleton.cs:102 
  at MvvmCross.Forms.Platforms.Ios.Core.MvxFormsApplicationDelegate.FinishedLaunching (UIKit.UIApplication uiApplication, Foundation.NSDictionary launchOptions) [0x0002a] in D:\a\1\s\MvvmCross.Forms\Platforms\Ios\Core\MvxFormsApplicationDelegate.cs:29 
  at BreathCompanion.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x000f1] in /Users/sebastian/WorkingCopy/git/BreathCompanion/BreathCompanion/BreathCompanion/BreathCompanion.iOS/AppDelegate.cs:113 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:65 
  at BreathCompanion.iOS.Application.Main (System.String[] args) [0x00001] in /Users/sebastian/WorkingCopy/git/BreathCompanion/BreathCompanion/BreathCompanion/BreathCompanion.iOS/Main.cs:12

@Sebastian1989101
Copy link

And yes, MvxSettings is already in a file referenced to prevent linking.

@PureWeen
Copy link

2020-07-13 17:22:32.671522+0200 BreathCompanion.iOS[33889:291042] Unhandled managed exception: Failed to find constructor for type MvvmCross.Core.MvxSettings (MvvmCross.Exceptions.MvxIoCResolveException)

The problem is that the constructor itself is being linked off the type because those types are instantiated via reflection.

So you have to do one of these things

i.e.

 <assembly fullname="My.Own.Assembly">
                <type fullname="Foo" preserve="fields">
                        <method name=".ctor" />
                </type>
        </assembly>

@Sebastian1989101
Copy link

@PureWeen This makes sense if I want to switch to Link all sometimes but why does the Release build with the old settings (Link SDK) no longer work? I update this app since 2017 on a regular base and never had such issues and as said only change was Xamarin.Forms 4.6 to 4.7 and the VS for Mac update.

@PureWeen
Copy link

I can't really do that much with the exception on the original post so I'm just trying to navigate towards a useful exception if at all possible. Without a repro and only Reason: image not found it's hard to give you any direct advice. 4.7 has been out for over a month and we don't have any other reports of this issue so there's something specific to your setup.

You could try doing a beyondcompare of the app folders to see what exactly is different. As you said one is a lot smaller than the other. It sounds like there's a specific dll that isn't getting included for you in 4.7 for whatever reason

@Sebastian1989101
Copy link

My guess is, because only mit Mapsui / SkiaSharp projects are affected by this, that either Mapsui.Forms or SkiaSharp.Views.Forms are using something through Reflection (because both are based on older Xamarin.Forms releases) which is getting linked out. I will try to put a list together of used functions and include them in the linker file to prevent them from getting linked out. But this will take a few hours/days because I just work in my spare time on these projects.

@PureWeen
Copy link

image not found sounds like something different than linking that just sounds like an entire dll is removed which is different than linking

You can also trying linkskipping Mapsui.Forms or SkiaSharp.Views.Forms to see if that fixes

If it doesn't than it's not the linker doing anything to those libraries

@Sebastian1989101
Copy link

@PureWeen I did a bunch of testing for this issue today. As I found out this has nothing todo with the linking at all. Because there is another difference between this project and my usual projects. This projects includes a today widget and a apple watch extension.

As soon as I remove the TodayExtension the app runs fine (which also matches pretty well with the missing size of the archive). Is there currently some kind of bug? I know that Xamarin support for the extensions is not very good at all but something like this might break some apps.

@PureWeen
Copy link

PureWeen commented Aug 4, 2020

@Sebastian1989101 is this relevant to your scenario?

#9048

@Sebastian1989101
Copy link

@PureWeen if I understand the linked topic correctly, this reflects to native written extensions? In this case, no. My TodayExtension was created with C# in VisualStudio it just stopped working with Forms 4.7 and the VS4Mac update.

@PureWeen
Copy link

PureWeen commented Aug 4, 2020

Given that you've isolated this down to

As soon as I remove the TodayExtension the app runs fine

Can you attach a repro that demonstrates the behavior?

@samhouts samhouts transferred this issue from xamarin/Xamarin.Forms Aug 5, 2020
@PureWeen
Copy link

PureWeen commented Aug 5, 2020

@rolfbjarne mentioned that this looks like a Xamarin.iOS bug so I'm moving here for now

But, not sure if they'll be able to pin it down without a reproduction

@rolfbjarne
Copy link
Member

But, not sure if they'll be able to pin it down without a reproduction

Yes, we'll need a test project to reproduce this in order to fix it.

@rolfbjarne rolfbjarne added iOS Issues affecting Xamarin.iOS need-info Waiting for more information before the bug can be investigated labels Aug 6, 2020
@rolfbjarne rolfbjarne added this to the Future milestone Aug 6, 2020
@Sebastian1989101
Copy link

This project does not 100% recreate the base issue but it shows already that the widget is not submitted to the device in a release build to a device. I'm not sure why it does not crash in this case like my real app does but it already shows that it is getting removed. Btw. this is with a fresh new project so I don't know why you need a test project if this can be recreated with the a new fresh project...
XamarinIssue9282.zip

@rolfbjarne
Copy link
Member

This project does not 100% recreate the base issue but it shows already that the widget is not submitted to the device in a release build to a device.

I don't quite understand the behavior you're seeing. Do you mean that the today extension doesn't show up in the list of today extensions on the device?

I'm not sure why it does not crash in this case like my real app
Btw. this is with a fresh new project so I don't know why you need a test project if this can be recreated with the a new fresh project...

We ask for a test project that can be used to reproduce the reported issue, because it's very common that there's something else going on (according to yourself it's not possible to reproduce the reported crash using a new fresh project), and then there's a lot of wasted time on both sides going back and forth trying to re-create the exact conditions that trigger the problem.

XamarinIssue9282.zip

I just tried this project, and both the extension and the app showed up when executed in release mode.

Then I upgraded the projects to Xamarin.Forms v4.7.0.1260, but both the app and the extension continued to work fine.

@Sebastian1989101
Copy link

@rolfbjarne I tested it with this project on 3 devices - all the same. The today extension is not included in a release build on a device (it works on the simulator for some reason). I also asked in my team others to test it and so far it is the same for all 5 who tested with it yet. The today extension is always just not commited to the device (3D-Touch / Force Touch just makes the background blur and wiggle once and the today extension is not accessable on the widget page). I still don't know why this app does not crash as our real app does but it seems like the today extension is just removed there as well.

All who tested it from my team are using the latest stable release of Visual Studio for Mac as of today.

@rolfbjarne
Copy link
Member

@Sebastian1989101 one thing you can do to narrow it down is to compare the build options between Debug and Release (the Build/iOS* project option pages), and try to figure out which option causes the project to fail (either by making the Debug configuration look like the Release configuration one option at a time, or the other way around).

@donaldashworth
Copy link

What's going on with this? I have had the same problem after upgrading to Xamarin 4.8. After upgrading, suddenly I began receiving the iOS depreciated UIWebView warning from App Store Connect. After finding zero help on this I opted to change a few compilation options until I was able to create a warning-less build...and then this happens when I switch to "Link All" instead of "Link Framework SDKs Only".

I got Xamm'ed twice in one day. A new record.

In all seriousness, I have never seen so many problems with a technology. Russian Roulette would render better results.

@donaldashworth
Copy link

These additional mtouch arguments ridded the App Store Connect depreciated UIWebView warning...

--optimize=experimental-xforms-product-type --optimize=+force-rejected-types-removal

@donaldashworth
Copy link

Sadly, I just discovered this causes an app crash when my UIWebView screen is accessed.

@rolfbjarne
Copy link
Member

@donaldashworth I'm sorry you're having such a hard time with out product. From what I understand you were able to find a solution to the UIWebView warning, but your app is still crashing? If that's the case, please open a new issue and describe your the problem there, since it might be something different that what's reported here, and having two separate problems in a single issue will lead to a lot of unnecessary confusion.

@Sebastian1989101
Copy link

@donaldashworth This issue is related to the today extension in iOS. The app crashes right away when a today extension is included. If you still use a UIWebView you should switch to a WkWebView because UIWebView is obsolete.

@donaldashworth
Copy link

donaldashworth commented Sep 24, 2020 via email

@tj-devel709
Copy link
Contributor

We have not received the requested information.

If you are still experiencing this issue please provide all the requested information then click the Reopen Issue button.

Thanks!

@xamarin xamarin locked as resolved and limited conversation to collaborators Apr 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Issues affecting Xamarin.iOS need-info Waiting for more information before the bug can be investigated
Projects
None yet
Development

No branches or pull requests

7 participants