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

NativeEmbeddingDemo doesn't work. #454

Open
vallgrenerik opened this issue Mar 25, 2024 · 2 comments
Open

NativeEmbeddingDemo doesn't work. #454

vallgrenerik opened this issue Mar 25, 2024 · 2 comments

Comments

@vallgrenerik
Copy link

vallgrenerik commented Mar 25, 2024

Thank you @davidbritch for the examples at https://github.com/dotnet/maui-samples/tree/main/8.0/PlatformIntegration/NativeEmbeddingDemo

I'm currently migrating an Xamarin.iOS/Xamarin.Android application to net8.0-ios/android.
I would like to see how I could implement some MAUI controls into this application and found this sample, which looks exactly what I want.
However the Android/iOS samples does not work.
I get this error on Android:

[0:] Microsoft.Maui.FontManager: Warning: Unable to load font 'OpenSans-Regular.ttf' from assets.

Java.Lang.RuntimeException: Font asset not found OpenSans-Regular.ttf
   at Java.Interop.JniEnvironment.StaticMethods.CallStaticObjectMethod(JniObjectReference type, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 21452
   at Java.Interop.JniPeerMembers.JniStaticMethods.InvokeObjectMethod(String encodedMember, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniStaticMethods.cs:line 165
   at Android.Graphics.Typeface.CreateFromAsset(AssetManager mgr, String path) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Android.Graphics.Typeface.cs:line 637
   at Microsoft.Maui.FontManager.LoadTypefaceFromAsset(String fontfamily, Boolean warning) in D:\a\_work\1\s\src\Core\src\Fonts\FontManager.Android.cs:line 123
  --- End of managed Java.Lang.RuntimeException stack trace ---
java.lang.RuntimeException: Font asset not found OpenSans-Regular.ttf
	at android.graphics.Typeface.createFromAsset(Typeface.java:1061)
	at crc647e519ad4bad0e093.MainActivity.n_onCreate(Native Method)
	at crc647e519ad4bad0e093.MainActivity.onCreate(MainActivity.java:30)
	at android.app.Activity.performCreate(Activity.java:8595)
	at android.app.Activity.performCreate(Activity.java:8573)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3764)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:205)
	at android.os.Looper.loop(Looper.java:294)
	at android.app.ActivityThread.main(ActivityThread.java:8177)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

  --- End of managed Java.Lang.RuntimeException stack trace ---
java.lang.RuntimeException: Font asset not found OpenSans-Regular.ttf
	at android.graphics.Typeface.createFromAsset(Typeface.java:1061)
	at crc647e519ad4bad0e093.MainActivity.n_onCreate(Native Method)
	at crc647e519ad4bad0e093.MainActivity.onCreate(MainActivity.java:30)
	at android.app.Activity.performCreate(Activity.java:8595)
	at android.app.Activity.performCreate(Activity.java:8573)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3764)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:205)
	at android.os.Looper.loop(Looper.java:294)
	at android.app.ActivityThread.main(ActivityThread.java:8177)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
[MaterialButton] MaterialButton manages its own background to control elevation, shape, color and states. Consider using backgroundTint, shapeAppearance and other attributes where available. A custom background will ignore these attributes and you should consider handling interaction states such as pressed, focused and disabled
[CompatibilityChangeReporter] Compat change id reported: 237531167; UID 10182; state: DISABLED
[OpenGLRenderer] Unknown dataspace 0
[Choreographer] Skipped 76 frames!  The application may be doing too much work on its main thread.
[OpenGLRenderer] Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
[OpenGLRenderer] Failed to initialize 101010-2 format, error = EGL_SUCCESS
[Gralloc4] mapper 4.x is not supported
[OpenGLRenderer] Unable to match the desired swap behavior.
Thread started: .NET Timer #5
[Glide] Load failed for [dotnet_bot.png] with dimensions [871x509]
[Glide] class com.bumptech.glide.load.engine.GlideException: Failed to load resource
[Glide] There were 3 root causes:
[Glide] java.io.FileNotFoundException(/dotnet_bot.png: open failed: ENOENT (No such file or directory))
[Glide] java.io.FileNotFoundException(open failed: ENOENT (No such file or directory))
[Glide] java.io.FileNotFoundException(open failed: ENOENT (No such file or directory))
[Glide]  call GlideException#logRootCauses(String) for more detail
[Glide]   Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, LOCAL
[Glide] There was 1 root cause:
[Glide] java.io.FileNotFoundException(/dotnet_bot.png: open failed: ENOENT (No such file or directory))
[Glide]  call GlideException#logRootCauses(String) for more detail
[Glide]     Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
[Glide] There was 1 root cause:
[Glide] java.io.FileNotFoundException(/dotnet_bot.png: open failed: ENOENT (No such file or directory))
[Glide]  call GlideException#logRootCauses(String) for more detail
[Glide]       Cause (1 of 1): class java.io.FileNotFoundException: /dotnet_bot.png: open failed: ENOENT (No such file or directory)
[Glide]   Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class android.os.ParcelFileDescriptor, LOCAL
[Glide] There was 1 root cause:
[Glide] java.io.FileNotFoundException(open failed: ENOENT (No such file or directory))
[Glide]  call GlideException#logRootCauses(String) for more detail
[Glide]     Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
[Glide] There was 1 root cause:
[Glide] java.io.FileNotFoundException(open failed: ENOENT (No such file or directory))
[Glide]  call GlideException#logRootCauses(String) for more detail
[Glide]       Cause (1 of 1): class java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
[Glide]   Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class android.content.res.AssetFileDescriptor, LOCAL
[Glide] There was 1 root cause:
[Glide] java.io.FileNotFoundException(open failed: ENOENT (No such file or directory))
[Glide]  call GlideException#logRootCauses(String) for more detail
[Glide]     Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
[Glide] There was 1 root cause:
[Glide] java.io.FileNotFoundException(open failed: ENOENT (No such file or directory))
[Glide]  call GlideException#logRootCauses(String) for more detail
[Glide]       Cause (1 of 1): class java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
[OpenGLRenderer] Davey! duration=1419ms; Flags=1, FrameTimelineVsyncId=35186, IntendedVsync=21020586168537, Vsync=21021852835153, InputEventId=0, HandleInputStart=21021856642791, AnimationStart=21021856645620, PerformTraversalsStart=21021856886831, DrawStart=21021927085481, FrameDeadline=21020602835203, FrameInterval=21021856272143, FrameStartTime=16666666, SyncQueued=21021943902737, SyncStart=21021944924305, IssueDrawCommandsStart=21021945682961, SwapBuffers=21021982637391, FrameCompleted=21022006370135, DequeueBufferDuration=2662, QueueBufferDuration=141899, GpuCompleted=21022006370135, SwapBuffersCompleted=21021989800530, DisplayPresentTime=0, CommandSubmissionCompleted=21021982637391, 
[Glide] Root cause (1 of 3)
[Glide] java.io.FileNotFoundException: /dotnet_bot.png: open failed: ENOENT (No such file or directory)
[Glide] 	at libcore.io.IoBridge.open(IoBridge.java:574)
[Glide] 	at java.io.FileInputStream.<init>(FileInputStream.java:160)
[Glide] 	at java.io.FileInputStream.<init>(FileInputStream.java:115)
[Glide] 	at android.content.ContentResolver.openInputStream(ContentResolver.java:1526)
[Glide] 	at com.bumptech.glide.load.data.StreamLocalUriFetcher.loadResourceFromUri(StreamLocalUriFetcher.java:74)
[Glide] 	at com.bumptech.glide.load.data.StreamLocalUriFetcher.loadResource(StreamLocalUriFetcher.java:50)
[Glide] 	at com.bumptech.glide.load.data.StreamLocalUriFetcher.loadResource(StreamLocalUriFetcher.java:13)
[Glide] 	at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:44)
[Glide] 	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:280)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
[Glide] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[Glide] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
[Glide] 	at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:424)
[Glide] 	at java.lang.Thread.run(Thread.java:1012)
[Glide] 	at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:383)
[Glide] Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
[Glide] 	at libcore.io.Linux.open(Native Method)
[Glide] 	at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
[Glide] 	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274)
[Glide] 	at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
[Glide] 	at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8063)
[Glide] 	at libcore.io.IoBridge.open(IoBridge.java:560)
[Glide] 	... 18 more
[Glide] Root cause (2 of 3)
[Glide] java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
[Glide] 	at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:351)
[Glide] 	at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:230)
[Glide] 	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1853)
[Glide] 	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1773)
[Glide] 	at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:20)
[Glide] 	at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:12)
[Glide] 	at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:44)
[Glide] 	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherFailed(DecodeJob.java:416)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.onLoadFailedInternal(SourceGenerator.java:223)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator$1.onLoadFailed(SourceGenerator.java:108)
[Glide] 	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:167)
[Glide] 	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:154)
[Glide] 	at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:50)
[Glide] 	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:280)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
[Glide] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[Glide] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
[Glide] 	at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:424)
[Glide] 	at java.lang.Thread.run(Thread.java:1012)
[Glide] 	at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:383)
[Glide] Root cause (3 of 3)
[Glide] java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
[Glide] 	at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:351)
[Glide] 	at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:230)
[Glide] 	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1853)
[Glide] 	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1773)
[Glide] 	at com.bumptech.glide.load.data.AssetFileDescriptorLocalUriFetcher.loadResource(AssetFileDescriptorLocalUriFetcher.java:20)
[Glide] 	at com.bumptech.glide.load.data.AssetFileDescriptorLocalUriFetcher.loadResource(AssetFileDescriptorLocalUriFetcher.java:11)
[Glide] 	at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:44)
[Glide] 	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherFailed(DecodeJob.java:416)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.onLoadFailedInternal(SourceGenerator.java:223)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator$1.onLoadFailed(SourceGenerator.java:108)
[Glide] 	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:167)
[Glide] 	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:154)
[Glide] 	at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:50)
[Glide] 	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherFailed(DecodeJob.java:416)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.onLoadFailedInternal(SourceGenerator.java:223)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator$1.onLoadFailed(SourceGenerator.java:108)
[Glide] 	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:167)
[Glide] 	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:154)
[Glide] 	at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:50)
[Glide] 	at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
[Glide] 	at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:280)
[Glide] 	at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
[Glide] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[Glide] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
[Glide] 	at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:424)
[Glide] 	at java.lang.Thread.run(Thread.java:1012)
[Glide] 	at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:383)
[Glide] Load failed for [crc6488302ad6e9e4df1a.ImageLoaderCallback@77743ec] with dimensions [871x509]
[Glide] class com.bumptech.glide.load.engine.GlideException: Failed to load resource
Thread started: <Thread Pool> #6
Thread started: .NET TP Gate #7
Thread started: <Thread Pool> #8
[monodroid-assembly] open_from_bundles: failed to load assembly System.Xml.XmlSerializer.dll
Loaded assembly: /data/data/com.companyname.nativeembeddingdemo/files/.__override__/System.Xml.XmlSerializer.dll [External]
**System.ArgumentNullException:** 'Value cannot be null. (Parameter 'key')'

[ProfileInstaller] Installing profile for com.companyname.nativeembeddingdemo
Thread finished: <Thread Pool> #8
The thread 8 has exited with code 0 (0x0).
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null. (Parameter 'key')
[mono-rt]    at System.ThrowHelper.ThrowArgumentNullException(String name)
[mono-rt]    at System.ThrowHelper.ThrowKeyNullException()
[mono-rt]    at System.Collections.Concurrent.ConcurrentDictionary`2[[Microsoft.Maui.Dispatching.IDispatcher, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.XamlHotReload.VisualTreeService.VisualTree.DispatcherVisualTreeContext, Microsoft.Maui.Controls.HotReload.Forms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetOrAdd(IDispatcher key, Func`2 valueFactory)
[mono-rt]    at Microsoft.XamlHotReload.VisualTreeService.VisualTree.VisualTreeContextBase.GetDispatcherContext(IDispatcher dispatcher) in D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Xaml\VisualTreeService\VisualTree\VisualTreeContextBase.cs:line 64
[mono-rt]    at Microsoft.XamlHotReload.VisualTreeService.VisualTree.FormsVisualTreeContext.<>c__DisplayClass12_0.<SubscribeToVisualTreeChanges>b__0() in D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Xaml\VisualTreeService\VisualTree\FormsVisualTreeContext.cs:line 58
[mono-rt]    at Microsoft.XamlHotReload.Utility.DispatcherExtensions.<>c__DisplayClass3_0.<InvokeAsync>b__0() in D:\a\_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\MauiDispatcherExtensions.cs:line 36
[mono-rt]    at Microsoft.XamlHotReload.Utility.DispatcherExtensions.<>c__DisplayClass4_0`1[[System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<InvokeAsync>b__1() in D:\a\_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\MauiDispatcherExtensions.cs:line 53
[mono-rt] --- End of stack trace from previous location ---
[mono-rt]    at Microsoft.XamlHotReload.Utility.DispatcherExtensions.Invoke(IDispatcher dispatcher, Action callback) in D:\a\_work\1\s\HotReload\Source\Microsoft.Maui.Controls.HotReload.Forms\MauiDispatcherExtensions.cs:line 17
[mono-rt]    at Microsoft.XamlHotReload.VisualTreeService.VisualTree.FormsVisualTreeContext.SubscribeToVisualTreeChanges() in D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Xaml\VisualTreeService\VisualTree\FormsVisualTreeContext.cs:line 57
[mono-rt]    at Microsoft.XamlHotReload.VisualTreeService.VisualTree.FormsVisualTreeContext.<.ctor>b__2_0(EmptyRequestInfo _) in D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Xaml\VisualTreeService\VisualTree\FormsVisualTreeContext.cs:line 30
[mono-rt]    at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.<>c__DisplayClass34_0`1[[Microsoft.VisualStudio.DesignTools.TapContract.TapOM.EmptyRequestInfo, Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null]].<RegisterMessageObserver>b__0(EmptyRequestInfo message)
[mono-rt]    at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.HandleMessage[EmptyRequestInfo,ResponseWithError](Func`2 callback, Message request)
[mono-rt]    at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.<>c__DisplayClass35_0`2[[Microsoft.VisualStudio.DesignTools.TapContract.TapOM.EmptyRequestInfo, Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.VisualStudio.DesignTools.TapContract.TapOM.ResponseWithError, Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null]].<RegisterMessageObserver>b__0(Message message)
[mono-rt]    at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ProcessInboundMessage(Message message)
[mono-rt]    at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.<>c__DisplayClass48_0.<OnMessageReceived>b__0()
[mono-rt]    at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.WaitableActionsList.<>c__DisplayClass8_0.<AddAndSignal>b__0(Boolean isCancelled)
[mono-rt]    at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ActionThread(Object list)
[mono-rt]    at System.Threading.Thread.StartCallback()

On iOS I get this error:

[0:] Microsoft.Maui.FileImageSourceService: Warning: Unable to load image file 'dotnet_bot.png'.

System.InvalidOperationException: Unable to load image file.
   at Microsoft.Maui.FileImageSourceService.GetImageAsync(IFileImageSource imageSource, Single scale, CancellationToken cancellationToken)
[0:] Microsoft.Maui.FontRegistrar: Warning: Unable to load font 'OpenSansRegular'.

System.IO.FileNotFoundException: Native font with the name OpenSans-Regular.ttf was not found.
   at Microsoft.Maui.FontRegistrar.GetNativeFontStream(String filename, String alias)
   at Microsoft.Maui.FontRegistrar.LoadNativeAppFont(String font, String filename, String alias)
   at Microsoft.Maui.FontRegistrar.GetFont(String font)
Thread started: .NET Timer #5
Thread started: <Thread Pool> #6
Thread started: .NET TP Gate #7
Thread started: <Thread Pool> #8
Loaded assembly: /Users/rum327/Library/Developer/CoreSimulator/Devices/B92C26C9-D9EF-4FA7-BDDF-2D67B5EEA13F/data/Containers/Bundle/Application/E8BCAF27-2809-467F-88F1-7D6D92D75FBF/NativeEmbeddingDemo.iOS.app/System.Xml.XmlSerializer.dll [External]
**System.ArgumentNullException:** 'Value cannot be null. (Parameter 'key')'

2024-03-25 15:15:57.893749+0100 NativeEmbeddingDemo.iOS[70361:9535933] 
Unhandled Exception:
System.ArgumentNullException: Value cannot be null. (Parameter 'key')
   at System.ThrowHelper.ThrowArgumentNullException(String name)
   at System.ThrowHelper.ThrowKeyNullException()
   at System.Collections.Concurrent.ConcurrentDictionary`2[[Microsoft.Maui.Dispatching.IDispatcher, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.VisualStudio.DesignTools.MobileTap.VisualTreeService.VisualTree.DispatcherVisualTreeContext, Microsoft.Maui.Controls.HotReload.Forms, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].GetOrAdd(IDispatcher key, Func`2 valueFactory)
   at Microsoft.VisualStudio.DesignTools.MobileTap.VisualTreeService.VisualTree.VisualTreeContextBase.GetDispatcherContext(IDispatcher dispatcher)
   at Microsoft.VisualStudio.DesignTools.MobileTap.VisualTreeService.VisualTree.FormsVisualTreeContext.<>c__DisplayClass9_0.<SubscribeToVisualTreeChanges>b__0()
   at M
icrosoft.VisualStudio.DesignTools.MobileTap.DispatcherExtensions.<>c__DisplayClass3_0.<InvokeAsync>b__0()
   at Microsoft.VisualStudio.DesignTools.MobileTap.DispatcherExtensions.<>c__DisplayClass4_0`1[[System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<InvokeAsync>b__1()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.DesignTools.MobileTap.DispatcherExtensions.Invoke(IDispatcher dispatcher, Action callback)
   at Microsoft.VisualStudio.DesignTools.MobileTap.VisualTreeService.VisualTree.FormsVisualTreeContext.SubscribeToVisualTreeChanges()
   at Microsoft.VisualStudio.DesignTools.MobileTap.VisualTreeService.VisualTree.FormsVisualTreeContext.<.ctor>b__2_0(EmptyRequestInfo _)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.<>c__DisplayClass34_0`1[[Microsoft.VisualStudio.DesignTools.TapContract.TapOM.EmptyRequestInfo, Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Culture=neu
tral, PublicKeyToken=b03f5f7f11d50a3a]].<RegisterMessageObserver>b__0(EmptyRequestInfo message)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.HandleMessage[EmptyRequestInfo,ResponseWithError](Func`2 callback, Message request)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.<>c__DisplayClass35_0`2[[Microsoft.VisualStudio.DesignTools.TapContract.TapOM.EmptyRequestInfo, Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.VisualStudio.DesignTools.TapContract.TapOM.ResponseWithError, Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].<RegisterMessageObserver>b__0(Message message)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ProcessInboundMessage(Message message)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.<>c__DisplayClass48_0.<OnMessageRece
ived>b__0()
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.WaitableActionsList.<>c__DisplayClass8_0.<AddAndSignal>b__0(Boolean isCancelled)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ActionThread(Object list)
   at System.Threading.Thread.StartCallback()
2024-03-25 15:15:57.897540+0100 NativeEmbeddingDemo.iOS[70361:9535933] Unhandled managed exception: Value cannot be null. (Parameter 'key') (System.ArgumentNullException)
   at System.ThrowHelper.ThrowArgumentNullException(String name)
   at System.ThrowHelper.ThrowKeyNullException()
   at System.Collections.Concurrent.ConcurrentDictionary`2[[Microsoft.Maui.Dispatching.IDispatcher, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.VisualStudio.DesignTools.MobileTap.VisualTreeService.VisualTree.DispatcherVisualTreeContext, Microsoft.Maui.Controls.HotReload.Forms, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].GetOrAdd(IDispatcher key, Func`2 valueFactory)
   at Microsoft.VisualStudio.DesignTools.MobileTap.VisualTreeService.VisualTree.VisualTreeContextBase.GetDispatcherContext(IDispatcher dispatcher)
   at Microsoft.VisualStudio.DesignTools.MobileTap.VisualTreeService.VisualTree.FormsVisualTreeContext.<>c__DisplayClass9_0.<SubscribeToVisualTreeChanges>b__0()

   at Microsoft.VisualStudio.DesignTools.MobileTap.DispatcherExtensions.<>c__DisplayClass3_0.<InvokeAsync>b__0()
   at Microsoft.VisualStudio.DesignTools.MobileTap.DispatcherExtensions.<>c__DisplayClass4_0`1[[System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<InvokeAsync>b__1()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.DesignTools.MobileTap.DispatcherExtensions.Invoke(IDispatcher dispatcher, Action callback)
   at Microsoft.VisualStudio.DesignTools.MobileTap.VisualTreeService.VisualTree.FormsVisualTreeContext.SubscribeToVisualTreeChanges()
   at Microsoft.VisualStudio.DesignTools.MobileTap.VisualTreeService.VisualTree.FormsVisualTreeContext.<.ctor>b__2_0(EmptyRequestInfo _)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.<>c__DisplayClass34_0`1[[Microsoft.VisualStudio.DesignTools.TapContract.TapOM.EmptyRequestInfo, Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Cul
ture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].<RegisterMessageObserver>b__0(EmptyRequestInfo message)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.HandleMessage[EmptyRequestInfo,ResponseWithError](Func`2 callback, Message request)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.<>c__DisplayClass35_0`2[[Microsoft.VisualStudio.DesignTools.TapContract.TapOM.EmptyRequestInfo, Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.VisualStudio.DesignTools.TapContract.TapOM.ResponseWithError, Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].<RegisterMessageObserver>b__0(Message message)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ProcessInboundMessage(Message message)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.<>c__DisplayClass48_0.<OnMes
sageReceived>b__0()
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.WaitableActionsList.<>c__DisplayClass8_0.<AddAndSignal>b__0(Boolean isCancelled)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ActionThread(Object list)
   at System.Threading.Thread.StartCallback()

=================================================================
	Native Crash Reporting
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
	Native stacktrace:
=================================================================
	0x102dd40a0 - /Users/rum327/Library/Developer/CoreSimulator/Devices/B92C26C9-D9EF-4FA7-BDDF-2D67B5EEA13F/data/Containers/Bundle/Application/E8BCAF27-2809-467F-88F1-7D6D92D75FBF/NativeEmbeddingDemo.iOS.app/libmonosgen-2.0.dylib : mono_dump_native_crash_info
	0x102d8428c - /Users/rum327/Library/Developer/CoreSimulator/Devices/B92C26C9-D9EF-4FA7-BDDF-2D67B5EEA13F/data/Containers/Bundle/Application/E8BCAF27-2809-467F-88F1-7D6D92D75FBF/NativeEmbeddingDemo.iOS.app/libmonosgen-2.0.dylib : mono_handle_native_crash
	0x1030a6bc8 - /Users/rum327/Library/Developer/CoreSimulator/Devices/B92C26C9-D9EF-4FA7-BDDF-2D67B5EEA13F/data/Containers/Bundle/Application/E8BCAF27-2809-467F-88F1-7D6D92D75FBF/NativeEmbeddingDemo.iOS.app/libmonosgen-2.0.dylib : sigabrt_signal_handler.cold.1
	0x102dd3960 - /Users/rum327/Library/Developer/CoreSimulator/Devices/B92C26C9-D9EF-4FA7-BDDF-2D67B5EEA13F/data/Containers/Bundle/Application/E8BCAF27-2809-467F-88F1-7D6D92D75FBF/NativeEmbeddingDemo.iOS.app/libmonosgen-2.0.dylib : mono_runtime_setup_stat_profiler
	0x1011dfc60 - /usr/lib/system/libsystem_platform.dylib : _sigtramp
	0x1012571d0 - /usr/lib/system/libsystem_pthread.dylib : pthread_kill
	0x1801605cc - /Library/Developer/CoreSimulator/Volumes/iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_c.dylib : abort
	0x102333098 - /Users/rum327/Library/Developer/CoreSimulator/Devices/B92C26C9-D9EF-4FA7-BDDF-2D67B5EEA13F/data/Containers/Bundle/Application/E8BCAF27-2809-467F-88F1-7D6D92D75FBF/NativeEmbeddingDemo.iOS.app/libxamarin-dotnet-debug.dylib : xamarin_find_protocol_wrapper_type
	0x102e610c4 - /Users/rum327/Library/Developer/CoreSimulator/Devices/B92C26C9-D9EF-4FA7-BDDF-2D67B5EEA13F/data/Containers/Bundle/Application/E8BCAF27-2809-467F-88F1-7D6D92D75FBF/NativeEmbeddingDemo.iOS.app/libmonosgen-2.0.dylib : mono_invoke_unhandled_exception_hook
	0x102ec38b4 - /Users/rum327/Library/Developer/CoreSimulator/Devices/B92C26C9-D9EF-4FA7-BDDF-2D67B5EEA13F/data/Containers/Bundle/Application/E8BCAF27-2809-467F-88F1-7D6D92D75FBF/NativeEmbeddingDemo.iOS.app/libmonosgen-2.0.dylib : start_wrapper
	0x1012574c0 - /usr/lib/system/libsystem_pthread.dylib : _pthread_start
	0x1012526f0 - /usr/lib/system/libsystem_pthread.dylib : thread_start

=================================================================
	Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x1022749ec):0x1022749dc  c0 03 5f d6 c0 03 5f d6 10 29 80 d2 01 10 00 d4  .._..._..)..
....
0x1022749ec  e3 00 00 54 fd 7b bf a9 fd 03 00 91 ce e2 ff 97  
...T.{..........
0x1022749fc  bf 03 00 91 fd 7b c1 a8 c0 03 5f d6 c0 
03 5f d6  .....{...._..._.
0x102274a0c  70 0a 
80 d2 01 10 00 d4 e3 00 00 54 fd 7b bf a9  p..........
T.{..

=================================================================
	Managed Stacktrace:
=================================================================
=================================================================

Any ideas @davidbritch @jfversluis ? 😊

@vallgrenerik
Copy link
Author

The iOS crash display some static resources problem (dotnet-bot.png) and I tried to remove those references but it still crashes on startup after a couple of seconds.

I'm using
Microsoft Visual Studio Professional 2022 (64-bit) - Preview Version 17.10.0 Preview 2.0

@davidbritch
Copy link
Contributor

Hi @vallgrenerik

Re: System.ArgumentNullException: Value cannot be null. (Parameter 'key')

This is actually a hot reload error. Hot reload doesn't work with native embedding apps. I added a note to the doc about this, but forgot to add it to the sample readme (I'll rectify this). So you have two options: (1) disable hot reload in VS, or (2) launch the app without debugging. This should get you over the first hurdle.

Native embedding seems to work on Android and Windows, but it's problematic on iOS and Mac Catalyst. The main issue on iOS/MacCat is that you can't interact with any MAUI controls you add to your native app, due to this issue. This alone is a blocker on those platforms. On top of that, iOS/MacCat won't load a single project in the latest MAUI release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants