I'm getting the following exception when starting the AllControls sample, for both iOS, Android and macOS (and I guess the other platforms too?):
System.InvalidProgramException: Invalid IL code in AllControls.AppModule:view (AllControls.Model,Microsoft.FSharp.Core.FSharpFunc`2<AllControls.Msg, Microsoft.FSharp.Core.Unit>): IL_28a2: stloc 953
at <StartupCode$AllControls>[email protected] (AllControls.Model model, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] dispatch) [0x00000] in /Users/timothelariviere/Git/GitHub/Fabulous/Fabulous.XamarinForms/samples/AllControls/AllControls/AllControls.fs:1062
at Fabulous.ProgramModule+traceView@210[model,msg,arg].Invoke (model model, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] dispatch) [0x00082] in /Users/timothelariviere/Git/GitHub/Fabulous/src/Fabulous/Program.fs:217
at Fabulous.ProgramRunner`3[arg,model,msg]..ctor (Fabulous.IHost host, Fabulous.Program`3[arg,model,msg] program, Microsoft.FSharp.Core.Unit arg) [0x00078] in /Users/timothelariviere/Git/GitHub/Fabulous/src/Fabulous/Program.fs:55
at Fabulous.ProgramModule.runWithFabulous[arg,model,msg] (Fabulous.IHost host, arg arg, Fabulous.Program`3[arg,model,msg] program) [0x00000] in /Users/timothelariviere/Git/GitHub/Fabulous/src/Fabulous/Program.fs:252
at Fabulous.XamarinForms.XamarinFormsProgramModule.runWith[a,b,c] (Xamarin.Forms.Application app, a arg, Fabulous.Program`3[arg,model,msg] program) [0x00007] in /Users/timothelariviere/Git/GitHub/Fabulous/Fabulous.XamarinForms/src/Fabulous.XamarinForms.Core/Program.fs:35
at Fabulous.XamarinForms.XamarinFormsProgramModule.run[a,b] (Xamarin.Forms.Application app, Fabulous.Program`3[arg,model,msg] program) [0x00000] in /Users/timothelariviere/Git/GitHub/Fabulous/Fabulous.XamarinForms/src/Fabulous.XamarinForms.Core/Program.fs:42
at AllControls.App..ctor () [0x0003b] in /Users/timothelariviere/Git/GitHub/Fabulous/Fabulous.XamarinForms/samples/AllControls/AllControls/AllControls.fs:1061
at iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication uiApp, Foundation.NSDictionary options) [0x00034] in /Users/timothelariviere/Git/GitHub/Fabulous/Fabulous.XamarinForms/samples/AllControls/iOS/AppDelegate.fs:18
at 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.4.0.2/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.4.0.2/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at iOS.Main.main (System.String[] args) [0x00000] in /Users/timothelariviere/Git/GitHub/Fabulous/Fabulous.XamarinForms/samples/AllControls/iOS/AppDelegate.fs:32
The view function seems to produce invalid IL.
I don't know why, it stopped working after #530 apparently.
Almost same code in https://github.com/fsprojects/Fabulous/tree/0.43.0 doesn't trigger the issue.
I played a little with the view function, and found that if I extract the code for the last match case (that we added recently, but there wasn't the issue at that moment) into its own function, the issue disappears...
Versions log
Visual Studio Enterprise 2019 for Mac
Version 8.3.5 (build 13)
Installation UUID: 97b76ad0-1550-4a4e-8af6-781cda196581
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.16.1.24 (d16-3 / 08809f5b)
Package version: 604000208
Mono Framework MDK
Runtime:
Mono 6.4.0.208 (2019-06/07c23f2ca43) (64-bit)
Package version: 604000208
NuGet
Version: 5.3.0.6192
.NET Core SDK
SDK: /usr/local/share/dotnet/sdk/3.0.100/Sdks
SDK Versions:
3.0.100
2.2.301
2.2.206
2.2.109
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/Sdks
.NET Core Runtime
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.0.0
2.2.7
2.2.6
2.1.13
Xamarin.Profiler
Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
Updater
Version: 11
Xamarin Designer
Version: 16.3.0.247
Hash: 52eac1a9e
Branch: remotes/origin/d16-3
Build date: 2019-10-03 23:04:28 UTC
Apple Developer Tools
Xcode 11.1 (15405)
Build 11A1027
Xamarin.Mac
Version: 6.4.0.2 (Visual Studio Enterprise)
Hash: e37549bc
Branch: xcode11.1
Build date: 2019-10-07 22:43:23-0400
Xamarin.iOS
Version: 13.4.0.2 (Visual Studio Enterprise)
Hash: e37549bc
Branch: xcode11.1
Build date: 2019-10-07 22:43:23-0400
Xamarin.Android
Version: 10.0.3.0 (Visual Studio Enterprise)
Commit: xamarin-android/d16-3/4d45b41
Android SDK: /Users/timothelariviere/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
None installed
SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.1
SDK Build Tools Version: 28.0.3
Build Information:
Mono: mono/mono/2019-06@5608fe0abb3
Java.Interop: xamarin/java.interop/d16-3@5836f58
LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94
LibZip: nih-at/libzip/rel-1-5-1@b95cf3fd
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.27.1@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-3@cb41333
Microsoft Mobile OpenJDK
Java SDK: /Users/timothelariviere/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
Android SDK Manager
Version: 1.4.0.65
Hash: c33b107
Branch: remotes/origin/d16-3
Build date: 2019-10-10 12:15:44 UTC
Android Device Manager
Version: 1.2.0.116
Hash: d2b2af0
Branch: remotes/origin/d16-3
Build date: 2019-10-10 12:16:06 UTC
Xamarin Inspector
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1
Build Information
Release ID: 803050013
Git revision: 9ea9458e434c7b9f4e53ace3a461e2cdf966317f
Build date: 2019-10-24 13:08:01+00
Build branch: release-8.3
Xamarin extensions: ade6d975df7634a5d81feda320a6102e5bacf309
Operating System
Mac OS X 10.15.0
Darwin 19.0.0 Darwin Kernel Version 19.0.0
Wed Sep 25 20:18:50 PDT 2019
root:xnu-6153.11.26~2/RELEASE_X86_64 x86_64
Anyone getting the same issue?
@dsyme This one might interest you
Another interesting thing is that adding a new case in #576 (and extracting Effects into its own function) doesn't trigger the issue.
Is this only caused by effects ?
I mean extracting something else into a function still creates the issue ?
Ouch
If we can trim this down to a minimal repro that would be, well, fabulous....
@dsyme I made a repro as minimal as I could: https://github.com/TimLariviere/Fabulous/blob/repro-invalid-il/Fabulous.XamarinForms/samples/AllControls/AllControls/AllControls.fs
You can clone the branch directly to test it.
Things I found while reproing:
View.Something used inside the view function. Adding one too many crashes, removing whichever one fixes the issue.View.Something inside in a condition branch that doesn't execute counts toward the bugView.Something inside local functions (e.g. dependsOn) does not count toward the bugVersions log in first post)Cool. May be hitting a JIT limit on number of locals or the like. Does PEVerify pass ok?
PEVerify is not outputting anything for the AllControls.dll. I'm only getting an exit code of 0.
So I guess it's ok?
So I guess it's ok?
Yes, it must be a mono/Xamarin limitation
Most helpful comment
If we can trim this down to a minimal repro that would be, well, fabulous....