XamarinCommunityToolkit
XamarinCommunityToolkit copied to clipboard
[Bug] LocalizationResourceManager.Current.CurrentCulture crashes app
Description
When using XCT with LocalizationResourceManager I get weird crashes when I set a new culture on language switch in the settings page: LocalizationResourceManager.Current.CurrentCulture = cult;
When I restart the app, the same line is used on App startup and then I see the correct language. This worked before.
All the latest libraries and iOS version. Will test later on Android and with a test project.
Stacktrace
In App center I see this, not sure if it's related:
0x0000000102c74000 + 62754000
SIGABRT: *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]
Last Exception Backtrace
CoreFoundation
__exceptionPreprocess
libobjc.A.dylib
objc_exception_throw
CoreFoundation
_CFThrowFormattedException
CoreFoundation
-[__NSPlaceholderArray initWithObjects:count:]
CoreFoundation
-[__NSPlaceholderArray initWithObjects:count:]
CoreFoundation
+[NSArray arrayWithObjects:count:]
MyApp.iOS
0x0000000102c74000 + 62754000
MyApp.iOS
0x0000000102c74000 + 51190856
MyApp.iOS
0x0000000102c74000 + 51184416
MyApp.iOS
0x0000000102c74000 + 51184124
MyApp.iOS
0x0000000102c74000 + 51182116
MyApp.iOS
0x0000000102c74000 + 55589680
MyApp.iOS
0x0000000102c74000 + 77179188
MyApp.iOS
0x0000000102c74000 + 77160952
MyApp.iOS
0x0000000102c74000 + 77178864
MyApp.iOS
0x0000000102c74000 + 71633152
UIKitCore
-[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:]
MyApp.iOS
0x0000000102c74000 + 62680232
MyApp.iOS
0x0000000102c74000 + 55144896
MyApp.iOS
0x0000000102c74000 + 2052236
MyApp.iOS
0x0000000102c74000 + 11417056
MyApp.iOS
0x0000000102c74000 + 123453168
MyApp.iOS
0x0000000102c74000 + 124216992
MyApp.iOS
0x0000000102c74000 + 124242344
MyApp.iOS
0x0000000102c74000 + 123314908
MyApp.iOS
0x0000000102c74000 + 125316604
MyApp.iOS
0x0000000102c74000 + 2047696
A bit more info: after the crash I directly see this in de device output:
2022-04-04 21:19:09.077973+0200 MyApp.iOS[34052:341665] Xamarin.iOS: Unable to locate assembly 'MyApp.resources' (culture: 'es-ES')
2022-04-04 21:19:09.090994+0200 MyApp.iOS[34052:341665] dynamic_cast error 2: One or more of the following type_info's has hidden visibility or is defined in more than one translation unit. They should all have public visibility. N10__cxxabiv116__shim_type_infoE, id, N10__cxxabiv117__pbase_type_infoE.
This was posted 2 days ago by someone else about something iOS native, so maybe it has to do with some iOS change in recent version? https://developer.apple.com/forums/thread/703309
@jtorvald, Could you attach a small repro?
@pictos I'm trying to reproduce in a separate repo, but guess what: it works there. I will dig a bit deeper this week to see if I can find the cause.
Thank you @jtorvald
@pictos After hours of debugging to see what changed I came to the point where the crash happens because of a TabView being used in an active page in shell (not the current page but still in the background). Not sure how relevant but that tabview is used within a StateView.
In the sample project I use now the culture change works, but that is probably because it happens on the same page. So I would need to create a separate settings screen there in the same way to see if I can reproduce the error then. No time for that at this moment so... to be continued.
@jtorvald no problem, take your time. I can there's a lot of elements in the equation, having a repro will help a lot, thanks for moving this forward
@jtorvald Have you been able to solve this issue?