dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.98k stars 1.71k forks source link

[Mac] MAUI app targeting net6.0-maccatalyst crashes if some NuGets are referenced. #7179

Closed AndrewPlakhotnyi closed 2 years ago

AndrewPlakhotnyi commented 2 years ago

Description

MAUI app on Mac Catalyst with NLua NuGet crashes on startup. Probably the bug is not specific to the NLua NuGet.

The internal library liblua54 is linked to the path @rpath/liblua54.framework/Versions/A/liblua54 but the file is actually located at @rpath/liblua54.framework/liblua54. As a result, the app crashes with the error: Library not loaded: @rpath/liblua54.framework/Versions/A/liblua54

liblua54 is a result of building KeraLua

Steps to Reproduce

  1. Install MAUI development environment on Mac OS using this guide
  2. Create MAUI project
  3. Add NLua 1.6.0 NuGet package
  4. Build and run the project dotnet build -f net6.0-maccatalyst -t:Run
  5. Application crashes with the error Library not loaded: @rpath/liblua54.framework/Versions/A/liblua54

Version with bug

Release Candidate 3 (current)

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

macOS Monterey 12.3.1

Did you find any workaround?

patching the executable file fixes the problem install_name_tool -change @rpath/liblua54.framework/Versions/A/liblua54 @rpath/liblua54.framework/liblua54 MyMauiApp

However, this breaks the signature of the executable file.

Relevant log output

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               SingleMauiApp [30172]
Path:                  /Users/USER/Documents/*/SingleMauiApp.app/Contents/MacOS/SingleMauiApp
Identifier:            com.companyname.singlemauiapp
Version:               1.0 (1)
Code Type:             X86-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2022-05-13 12:56:53.1225 -0700
OS Version:            macOS 12.3.1 (21E258)
Report Version:        12
Bridge OS Version:     6.4 (19P4243)
Anonymous UUID:        98B9660E-6F18-FD9D-CDEB-65C6C86781D7

Sleep/Wake UUID:       EC264ED0-1CF1-4A42-A1FD-DB933F654A28

Time Awake Since Boot: 110000 seconds
Time Since Wake:       50267 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace DYLD, Code 1 Library missing
Library not loaded: @rpath/liblua54.framework/Versions/A/liblua54
Referenced from: /Users/USER/Documents/*/SingleMauiApp.app/Contents/MacOS/SingleMauiApp
Reason: tried: '/Users/andrew/Documents/h2n/SingleMauiApp/SingleMauiApp/bin/Debug/net6.0-maccatalyst/maccatalyst-x64/SingleMauiApp.app/Contents/MacOS/../MonoBundle/liblua54.framework/Versions/A/liblua54' (no such file), '/Users/andrew/Documents/h2n/SingleMauiApp/SingleMauiApp/bin/Debug/net6.0-maccatalyst/maccatalyst-x64/SingleMauiApp.app/Contents/MacOS/../Frameworks/liblua54.framework/Versions/A/liblua54' (no such file), '/Users/andrew/Documents/h2n/SingleMauiApp/SingleMauiApp/bin/Debug/net6.0-maccatalyst/maccatalyst-x64/SingleMauiApp.app/Contents/MacOS/../MonoBundle/liblua54.framework/Versions/A/liblua54' (no such file), '/Users/andrew/Documents/h2n/SingleMauiApp/SingleMauiApp/bin/Debug/net6.0-maccatalyst/maccatalyst-x64/SingleMauiApp.app/Contents/MacOS/../Frameworks/liblua54.
(terminated at launch; ignore backtrace)

Application Specific Information:
Library not loaded: @rpath/liblua54.framework/Versions/A/liblua54
Referenced from: /Users/andrew/Documents/h2n/SingleMauiApp/SingleMauiApp/bin/Debug/net6.0-maccatalyst/maccatalyst-x64/SingleMauiApp.app/Contents/MacOS/SingleMauiApp
Reason: tried: '/Users/andrew/Documents/h2n/SingleMauiApp/SingleMauiApp/bin/Debug/net6.0-maccatalyst/maccatalyst-x64/SingleMauiApp.app/Contents/MacOS/../MonoBundle/liblua54.framework/Versions/A/liblua54' (no such file), '/Users/andrew/Documents/h2n/SingleMauiApp/SingleMauiApp/bin/Debug/net6.0-maccatalyst/maccatalyst-x64/SingleMauiApp.app/Contents/MacOS/../Frameworks/liblua54.framework/Versions/A/liblua54' (no such file), '/Users/andrew/Documents/h2n/SingleMauiApp/SingleMauiApp/bin/Debug/net6.0-maccatalyst/maccatalyst-x64/SingleMauiApp.app/Contents/MacOS/../MonoBundle/liblua54.framework/Versions/A/liblua54' (no such file), '/Users/andrew/Documents/h2n/SingleMauiApp/SingleMauiApp/bin/Debug/net6.0-maccatalyst/maccatalyst-x64/SingleMauiApp.app/Contents/MacOS/../Frameworks/liblua54.

Thread 0 Crashed:
0   dyld                                   0x11d6f60de __abort_with_payload + 10
1   dyld                                   0x11d70c212 abort_with_payload_wrapper_internal + 80
2   dyld                                   0x11d70c244 abort_with_payload + 9
3   dyld                                   0x11d6ba76f dyld4::halt(char const*) + 375
4   dyld                                   0x11d6b65a5 dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 3995
5   dyld                                   0x11d6b54d4 start + 388

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000002000209  rbx: 0x0000000000000000  rcx: 0x00007ff7b1239348  rdx: 0x00007ff7b12397b0
  rdi: 0x0000000000000006  rsi: 0x0000000000000001  rbp: 0x00007ff7b1239390  rsp: 0x00007ff7b1239348
   r8: 0x00007ff7b12393b0   r9: 0x0000000000000000  r10: 0x00000000000000d6  r11: 0x0000000000000246
  r12: 0x00000000000000d6  r13: 0x00007ff7b12397b0  r14: 0x0000000000000001  r15: 0x0000000000000006
  rip: 0x000000011d6f60de  rfl: 0x0000000000000246  cr2: 0x000000011d6bce74

Logical CPU:     0
Error Code:      0x02000209 
Trap Number:     133

Binary Images:
       0x11d6b0000 -        0x11d71bfff dyld (*) <dd9e80de-fb3b-349b-96a4-46874ad34d11> /usr/lib/dyld

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=4824K resident=0K(0%) swapped_out_or_unallocated=4824K(100%)
Writable regions: Total=9396K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=9396K(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
STACK GUARD                       56.0M        1 
Stack                             8192K        1 
VM_ALLOCATE                         12K        3 
__DATA                             768K        3 
__DATA_CONST                       224K        2 
__LINKEDIT                        3296K        4 
__TEXT                            1552K        2 
dyld private memory               1024K        1 
===========                     =======  ======= 
TOTAL                             70.7M       17 

-----------
Full Report
-----------

{"app_name":"SingleMauiApp","timestamp":"2022-05-13 12:56:53.00 -0700","app_version":"1.0","slice_uuid":"6c47605a-b505-3e9b-8bea-88509c712e93","build_version":"1","platform":6,"bundleID":"com.companyname.singlemauiapp","share_with_app_devs":0,"is_first_party":0,"bug_type":"309","os_version":"macOS 12.3.1 (21E258)","incident_id":"CD425D84-49C5-4F4D-AFB1-67D6FDF12564","name":"SingleMauiApp"}
{
  "uptime" : 110000,
  "procLaunch" : "2022-05-13 12:56:52.8349 -0700",
  "procRole" : "Background",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "MacBookPro16,1",
  "procStartAbsTime" : 114533934403838,
  "coalitionID" : 19414,
  "osVersion" : {
    "train" : "macOS 12.3.1",
    "build" : "21E258",
    "releaseType" : "User"
  },
  "captureTime" : "2022-05-13 12:56:53.1225 -0700",
  "incident" : "CD425D84-49C5-4F4D-AFB1-67D6FDF12564",
  "bug_type" : "309",
  "pid" : 30172,
  "procExitAbsTime" : 114534221424058,
  "cpuType" : "X86-64",
  "procName" : "SingleMauiApp",
  "procPath" : "\/Users\/USER\/Documents\/*\/SingleMauiApp.app\/Contents\/MacOS\/SingleMauiApp",
  "bundleInfo" : {"CFBundleShortVersionString":"1.0","CFBundleVersion":"1","CFBundleIdentifier":"com.companyname.singlemauiapp"},
  "storeInfo" : {"deviceIdentifierForVendor":"304DA28A-FE6D-5537-8D2F-203E891F89C5","thirdParty":true},
  "parentProc" : "launchd",
  "parentPid" : 1,
  "coalitionName" : "com.companyname.singlemauiapp",
  "crashReporterKey" : "98B9660E-6F18-FD9D-CDEB-65C6C86781D7",
  "wakeTime" : 50267,
  "bridgeVersion" : {"build":"19P4243","train":"6.4"},
  "sleepWakeUUID" : "EC264ED0-1CF1-4A42-A1FD-DB933F654A28",
  "sip" : "enabled",
  "isCorpse" : 1,
  "exception" : {"codes":"0x0000000000000000, 0x0000000000000000","rawCodes":[0,0],"type":"EXC_CRASH","signal":"SIGABRT"},
  "termination" : {"code":1,"flags":518,"namespace":"DYLD","indicator":"Library missing","details":["(terminated at launch; ignore backtrace)"],"reasons":["Library not loaded: @rpath\/liblua54.framework\/Versions\/A\/liblua54","Referenced from: \/Users\/USER\/Documents\/*\/SingleMauiApp.app\/Contents\/MacOS\/SingleMauiApp","Reason: tried: '\/Users\/andrew\/Documents\/h2n\/SingleMauiApp\/SingleMauiApp\/bin\/Debug\/net6.0-maccatalyst\/maccatalyst-x64\/SingleMauiApp.app\/Contents\/MacOS\/..\/MonoBundle\/liblua54.framework\/Versions\/A\/liblua54' (no such file), '\/Users\/andrew\/Documents\/h2n\/SingleMauiApp\/SingleMauiApp\/bin\/Debug\/net6.0-maccatalyst\/maccatalyst-x64\/SingleMauiApp.app\/Contents\/MacOS\/..\/Frameworks\/liblua54.framework\/Versions\/A\/liblua54' (no such file), '\/Users\/andrew\/Documents\/h2n\/SingleMauiApp\/SingleMauiApp\/bin\/Debug\/net6.0-maccatalyst\/maccatalyst-x64\/SingleMauiApp.app\/Contents\/MacOS\/..\/MonoBundle\/liblua54.framework\/Versions\/A\/liblua54' (no such file), '\/Users\/andrew\/Documents\/h2n\/SingleMauiApp\/SingleMauiApp\/bin\/Debug\/net6.0-maccatalyst\/maccatalyst-x64\/SingleMauiApp.app\/Contents\/MacOS\/..\/Frameworks\/liblua54."]},
  "asi" : {"dyld":["Library not loaded: @rpath\/liblua54.framework\/Versions\/A\/liblua54","Referenced from: \/Users\/andrew\/Documents\/h2n\/SingleMauiApp\/SingleMauiApp\/bin\/Debug\/net6.0-maccatalyst\/maccatalyst-x64\/SingleMauiApp.app\/Contents\/MacOS\/SingleMauiApp","Reason: tried: '\/Users\/andrew\/Documents\/h2n\/SingleMauiApp\/SingleMauiApp\/bin\/Debug\/net6.0-maccatalyst\/maccatalyst-x64\/SingleMauiApp.app\/Contents\/MacOS\/..\/MonoBundle\/liblua54.framework\/Versions\/A\/liblua54' (no such file), '\/Users\/andrew\/Documents\/h2n\/SingleMauiApp\/SingleMauiApp\/bin\/Debug\/net6.0-maccatalyst\/maccatalyst-x64\/SingleMauiApp.app\/Contents\/MacOS\/..\/Frameworks\/liblua54.framework\/Versions\/A\/liblua54' (no such file), '\/Users\/andrew\/Documents\/h2n\/SingleMauiApp\/SingleMauiApp\/bin\/Debug\/net6.0-maccatalyst\/maccatalyst-x64\/SingleMauiApp.app\/Contents\/MacOS\/..\/MonoBundle\/liblua54.framework\/Versions\/A\/liblua54' (no such file), '\/Users\/andrew\/Documents\/h2n\/SingleMauiApp\/SingleMauiApp\/bin\/Debug\/net6.0-maccatalyst\/maccatalyst-x64\/SingleMauiApp.app\/Contents\/MacOS\/..\/Frameworks\/liblua54."]},
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":1120444,"threadState":{"r13":{"value":140701805549488},"rax":{"value":33554953},"rflags":{"value":582},"cpu":{"value":0},"r14":{"value":1},"rsi":{"value":1},"r8":{"value":140701805548464},"cr2":{"value":4788571764},"rdx":{"value":140701805549488},"r10":{"value":214},"r9":{"value":0},"r15":{"value":6},"rbx":{"value":0},"trap":{"value":133},"err":{"value":33554953},"r11":{"value":582},"rip":{"value":4788805854,"matchesCrashFrame":1},"rbp":{"value":140701805548432},"rsp":{"value":140701805548360},"r12":{"value":214},"rcx":{"value":140701805548360},"flavor":"x86_THREAD_STATE","rdi":{"value":6}},"frames":[{"imageOffset":286942,"symbol":"__abort_with_payload","symbolLocation":10,"imageIndex":0},{"imageOffset":377362,"symbol":"abort_with_payload_wrapper_internal","symbolLocation":80,"imageIndex":0},{"imageOffset":377412,"symbol":"abort_with_payload","symbolLocation":9,"imageIndex":0},{"imageOffset":42863,"symbol":"dyld4::halt(char const*)","symbolLocation":375,"imageIndex":0},{"imageOffset":26021,"symbol":"dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*)","symbolLocation":3995,"imageIndex":0},{"imageOffset":21716,"symbol":"start","symbolLocation":388,"imageIndex":0}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "x86_64",
    "base" : 4788518912,
    "size" : 442368,
    "uuid" : "dd9e80de-fb3b-349b-96a4-46874ad34d11",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  }
],
  "sharedCache" : {
  "base" : 140703353835520,
  "size" : 15224815616,
  "uuid" : "6cc5ecdc-5119-37f0-9a85-4f48a50f5f78"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=4824K resident=0K(0%) swapped_out_or_unallocated=4824K(100%)\nWritable regions: Total=9396K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=9396K(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nSTACK GUARD                       56.0M        1 \nStack                             8192K        1 \nVM_ALLOCATE                         12K        3 \n__DATA                             768K        3 \n__DATA_CONST                       224K        2 \n__LINKEDIT                        3296K        4 \n__TEXT                            1552K        2 \ndyld private memory               1024K        1 \n===========                     =======  ======= \nTOTAL                             70.7M       17 \n",
  "legacyInfo" : {
  "threadTriggered" : {

  }
},
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "60356660bbe37970735c5624",
      "factorPackIds" : {

      },
      "deploymentId" : 240000027
    },
    {
      "rolloutId" : "5fc94383418129005b4e9ae0",
      "factorPackIds" : {

      },
      "deploymentId" : 240000370
    }
  ],
  "experiments" : [

  ]
}
}

Model: MacBookPro16,1, BootROM 1731.100.130.0.0 (iBridge: 19.16.14243.0.0,0), 8 processors, 8-Core Intel Core i9, 2.3 GHz, 16 GB, SMC 
Graphics: Intel UHD Graphics 630, Intel UHD Graphics 630, Built-In
Graphics: AMD Radeon Pro 5500M, AMD Radeon Pro 5500M, PCIe, 4 GB
Display: Color LCD, 3072 x 1920 Retina, MirrorOff, Online
Display: LG HDR 4K, 3840 x 2160 (2160p/4K UHD 1 - Ultra High Definition), Main, MirrorOff, Online
Memory Module: BANK 0/ChannelA-DIMM0, 8 GB, DDR4, 2667 MHz, Micron, 8ATF1G64HZ-2G6E1
Memory Module: BANK 2/ChannelB-DIMM0, 8 GB, DDR4, 2667 MHz, Micron, 8ATF1G64HZ-2G6E1
AirPort: spairport_wireless_card_type_wifi (0x14E4, 0x7BF), wl0: Jul 12 2021 18:02:56 version 9.30.464.0.32.5.76 FWID 01-c081cfed
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB3.0 Hub
USB Device: USB31Bus
USB Device: 4-Port USB 2.0 Hub
USB Device: USB2.0 Hub
USB Device: ZOWIE Gaming mouse
USB Device: Razer Kraken Ultimate
USB Device: SteelSeries Apex Pro
USB Device: T2Bus
USB Device: composite_device
USB Device: Touch Bar Backlight
USB Device: Touch Bar Display
USB Device: Apple Internal Keyboard / Trackpad
USB Device: Headset
USB Device: Ambient Light Sensor
USB Device: FaceTime HD Camera (Built-in)
USB Device: Apple T2 Controller
Thunderbolt Bus: MacBook Pro, Apple Inc., 63.5
Thunderbolt Bus: MacBook Pro, Apple Inc., 63.5
drasticactions commented 2 years ago

If you try creating a new dotnet 6 Mac Catalyist app, without MAUI (dotnet new maccatalyst) and try doing that, does it still crash?

I have a feeling this is an issue specific to dotnet 6 Mac Catalyst itself, not the MAUI UI Framework things in this repo.

ghost commented 2 years ago

Hi @AndrewPlakhotnyi. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

suuunly commented 2 years ago

This is still an issue. I created a maui app through Jetbrains Rider. It builds perfectly fine to Android and iOS. However, if I reference a Razor Class Library like so in the maui project: `

`

then it fails across the board with the following error:

Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(427, 5): [NETSDK1082] There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'maccatalyst-x64'. Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(427, 5): [NETSDK1082] There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'iossimulator-x64'. Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(427, 5): [NETSDK1082] There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'android-arm'. Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(427, 5): [NETSDK1082] There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'android-arm64'. Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(427, 5): [NETSDK1082] There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'android-x86'. Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(427, 5): [NETSDK1082] There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'android-x64'.

suuunly commented 2 years ago

Nevermind, I found the issue. The issue lies with an internal package that I was referencing - which does not seem to be compatible with MAUI. After removing it, it runs perfectly fine

PureWeen commented 2 years ago

If you try creating a new dotnet 6 Mac Catalyist app, without MAUI (dotnet new maccatalyst) and try doing that, does it still crash?

I have a feeling this is an issue specific to dotnet 6 Mac Catalyst itself, not the MAUI UI Framework things in this repo.

@AndrewPlakhotnyi if you can respond to the question here we can reopen