I have an application with 4 tabs (TabActivity). By some reasons I call GC.Collect every time user switches tab (overriding OnPause Activity's method). Sometimes (approximately 1 time from 50-100 calls, but sometimes this happens when application just started) my application hangs in this moment.
Here is part of my code:
protected override void OnPause(){
base.OnPause();
try{
Android.Util.Log.Info("----","GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);");
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
Android.Util.Log.Info("----","GC.Collect Finished");
}catch(Exception exc){
Android.Util.Log.Info("exc.Message",exc.Message);
Android.Util.Log.Info("exc.StackTrace",exc.StackTrace);
throw exc;
}
}
And here is corresponding Android log output
//Previous GC.Collect call, it's all ok
I/---- ( 7796): GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
D/dalvikvm( 7796): GetMethodID: method not found: Landroid/widget/EditText;.monodroidAddReference:(Ljava/lang/Object;)V
D/dalvikvm( 7796): GC_EXPLICIT freed 962 objects / 42472 bytes in 112ms
I/---- ( 7796): GC.Collect Finished
//On another call fails
I/---- ( 7796): GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
I/mono ( 7796): Stacktrace:
I/mono ( 7796):
I/mono ( 7796): at System.GC.Collect (int) <0x0001f>
I/mono ( 7796): at System.GC.Collect (int,System.GCCollectionMode) <0x00017>
I/mono ( 7796): at PixelsAndroid.CustomActivity.OnPause () <0x00067>
I/mono ( 7796): at Android.App.Activity.n_OnPause (intptr,intptr) <0x00037>
I/mono ( 7796): at (wrapper dynamic-method) object.908cefd4-40eb-4dd1-97cd-f731b2ada74a (intptr,intptr) <0x0002b>
I/mono ( 7796): at (wrapper native-to-managed) object.908cefd4-40eb-4dd1-97cd-f731b2ada74a (intptr,intptr) <0xffffffff>
No any exception to been thrown, no any visible reason to fail. Application just hangs, after few seconds I get Android OS alert: "Oppps, your application got stuck. Force close or wait?"
Anybody faced with it?
There was a bug in some old versions of monodroid: if you call GC.Collect and an http request in a parallel threads, this caused crash. Update to a latest version of monodroid.
Having to do a GC.Collect() under any circumstance is a bad code smell. Figure out the underlying reason and perform corrective rearchitecture.
Related
After updating my game, Firebase crashes. I upgrade first to the last version 5.4.0 but still got the same error. I downgrade to 5.2.0 but nothing change. On my console, using adb logcat, I have :
11-04 01:37:37.420 1318 1333 W HwPolicyFactoryImpl: mAware is disable
11-04 01:37:37.462 12161 12308 E Unity : DllNotFoundException: FirebaseCppApp-5.2.0
11-04 01:37:37.462 12161 12308 E Unity : at (wrapper managed-to-native) Firebase.AppUtilPINVOKE/SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_AppUtil (Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate)
11-04 01:37:37.462 12161 12308 E Unity : at Firebase.AppUtilPINVOKE+SWIGExceptionHelper..cctor () [0x00000] in <filename unknown>:0
11-04 01:37:37.462 12161 12308 E Unity : Rethrow as TypeInitializationException: An exception was thrown by the type initialize
11-04 01:37:37.792 1318 1478 E WifiConfigManager: updateConfiguration freq=2467 BSSID=14:0c:**:**:fa:dc RSSI=-66 "TuNeTeConnecterasPas"WPA_PSK
11-04 01:37:38.188 1318 1542 E HwCHRWifiRSSIGroupSummery: updatArpSummery mRSSI:-66 HwCHRWifiRSSIGroup [rssi_index=3, rtt_tcp_packets=824, rtt_tcp_duration=58535, rtt_lan_duration=3215, rtt_lan_failures=0, rtt_lan_succ=161, rtt_lan_max=73, rtt_lan_min=4,same_area_frequency=0,adjacent_area_frequency=0]
11-04 01:37:38.401 1318 1318 I TrafficMonitor: expired arrive. level:-1
11-04 01:37:38.401 1318 1318 I TrafficMonitor: during_ms:2001,period_ms:2000
Please could you know how could I correct it ?
I use unity 2018, jdk8, target android 27.
I am developing an android app Using UrhoSharp. I have created a SDLSurface as;
surface = UrhoSurface.CreateSurface (this, typeof(UrhoLayer), appOptions);
When I press back button the app crashes after some time. The app seems to crash only when UrhoSurface.OnDestroy() is called. Here is the stacktrace;
[SDL] onDestroy()
[SDL] nativeQuit()
[Mono] [0x7192d4d8] hill climbing, change max number of threads 126
[Mono] DllImport searching in: 'mono-urho' ('libmono-urho.so').
[Mono] Searching for 'TryDeleteRefCounted'.
[Mono] Probing 'TryDeleteRefCounted'.
[Mono] Found as 'TryDeleteRefCounted'.
[Mono] GC_BRIDGE waiting for bridge processing to finish
[Mono] GC_OLD_BRIDGE num-objects 1519 num_hash_entries 1762 sccs size 1762 init 0.00ms df1 5.28ms sort 3.72ms dfs2 1.98ms setup-cb 1.65ms free-data 5.77ms links 421/421/1071/17 dfs passes 3702/2183
[Mono] GC_MAJOR: (user request) pause 41.87ms, total 44.04ms, bridge 0.03ms major 1904K/0K los 180K/0K
Thread started: <Thread Pool> #15
Thread started: <Thread Pool> #16
Thread started: <Thread Pool> #17
[Mono] [0x6e635b30] worker starting
[Mono] [0x6d788a28] worker starting
[Mono] [0x701cf728] worker starting
[Mono] GC_OLD_BRIDGE num-objects 443 num_hash_entries 620 sccs size 620 init 0.00ms df1 3.39ms sort 0.43ms dfs2 1.86ms setup-cb 0.67ms free-data 1.19ms links 319/319/969/17 dfs passes 1382/939
[Mono] GC_MAJOR: (user request) pause 25.58ms, total 25.76ms, bridge 0.00ms major 1808K/0K los 180K/0K
[Mono] DllImport searching in: 'mono-urho' ('libmono-urho.so').
[Mono] Searching for 'RefCounted_ReleaseRef'.
[Mono] Probing 'RefCounted_ReleaseRef'.
[Mono] Found as 'RefCounted_ReleaseRef'.
[mono-rt] Stacktrace:
[mono-rt]
[mono-rt]
[mono-rt] Attempting native Android stacktrace:
[mono-rt]
[mono-rt] at ???+132 [0x597f3084]
[mono-rt] at ???+16380 [0x597f2ffc]
[mono-rt]
[mono-rt] =================================================================
[mono-rt] Got a SIGSEGV while executing native code. This usually indicates
[mono-rt] a fatal error in the mono runtime or one of the native libraries
[mono-rt] used by your application.
[mono-rt] =================================================================
[mono-rt]
[libc] Fatal signal 11 (SIGSEGV) at 0x597f3084 (code=2), thread 2835 (SDLThread)
I am facing a NullReferenceException when starting an Xamarin Android App via Visual Studio 2015.
It is thrown after leaving the OnCreate() in my main activity, but I do not know where and why. How can find more information about this error?
The Debug output is like this:
05-21 20:18:51.643 D/OpenGLRenderer(25574): Use EGL_SWAP_BEHAVIOR_PRESERVED: true
05-21 20:18:51.651 D/Atlas (25574): Validating map...
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
Exception:
System.NullReferenceException: Object reference not set to an instance of an object
05-21 20:19:37.436 D/Mono (25574): DllImport attempting to load: '/system/lib/liblog.so'.
05-21 20:19:37.436 D/Mono (25574): DllImport loaded library '/system/lib/liblog.so'.
05-21 20:19:37.436 D/Mono (25574): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
05-21 20:19:37.436 D/Mono (25574): Searching for '__android_log_print'.
05-21 20:19:37.436 D/Mono (25574): Probing '__android_log_print'.
05-21 20:19:37.437 D/Mono (25574): Found as '__android_log_print'.
05-21 20:19:37.450 I/MonoDroid(25574): UNHANDLED EXCEPTION:
05-21 20:19:37.454 I/MonoDroid(25574): System.NullReferenceException: Object reference not set to an instance of an object
05-21 20:19:37.454 I/MonoDroid(25574): at Xamarin.Forms.Platform.Android.KeyboardManager.HideKeyboard (Android.Views.View inputView, Boolean overrideValidation) [0x00000] in C:\BuildAgent3\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\KeyboardManager.cs:14
05-21 20:19:37.454 I/MonoDroid(25574): at Xamarin.Forms.Platform.Android.FormsApplicationActivity.OnPause () [0x00000] in C:\BuildAgent3\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\FormsApplicationActivity.cs:153
05-21 20:19:37.455 I/MonoDroid(25574): at Android.App.Activity.n_OnPause (IntPtr jnienv, IntPtr native__this) [0x00009] in /Users/builder/data/lanes/3236/ee215fc9/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:4046
05-21 20:19:37.455 I/MonoDroid(25574): at (wrapper dynamic-method) System.Object:5c198319-5b9a-4152-9518-5aa3ce7cab6e (intptr,intptr)
05-21 20:19:37.476 W/art (25574): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable
An unhandled exception occured.
05-21 20:19:38.791 E/mono (25574):
05-21 20:19:38.791 E/mono (25574): Unhandled Exception:
05-21 20:19:38.791 E/mono (25574): System.NullReferenceException: Object reference not set to an instance of an object
05-21 20:19:38.791 E/mono (25574): at (wrapper dynamic-method) System.Object:5c198319-5b9a-4152-9518-5aa3ce7cab6e (intptr,intptr)
05-21 20:19:38.791 E/mono (25574): at (wrapper native-to-managed) System.Object:5c198319-5b9a-4152-9518-5aa3ce7cab6e (intptr,intptr)
05-21 20:19:38.792 E/mono-rt (25574): [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
05-21 20:19:38.792 E/mono-rt (25574): at (wrapper dynamic-method) System.Object:5c198319-5b9a-4152-9518-5aa3ce7cab6e (intptr,intptr)
05-21 20:19:38.792 E/mono-rt (25574): at (wrapper native-to-managed) System.Object:5c198319-5b9a-4152-9518-5aa3ce7cab6e (intptr,intptr)
referenceTable GDEF length=670 1
referenceTable GSUB length=7202 1
referenceTable GPOS length=24560 1
I know it's been a while but perhaps I can help someone in the future. Something similar happened to me when I accidentally removed the initiation of my App.Current.Mainpage while the app was starting up. Silly mistake that leads to an unhelpful error message.
Got the idea on where my problem was from here: https://bugzilla.xamarin.com/show_bug.cgi?id=36287
I used the below code piece to read barcode using Zxing barcode library which is downloaded from http://components.xamarin.com/gettingstarted/zxing.net.mobile. Application minVersion is selected as 2.3 and target version is selected as Automatic. I'am running the app on nexus 4 (Android 4.4.2)
BarcodeButton.Click += async delegate
{
var scanner = new ZXing.Mobile.MobileBarcodeScanner(this);
var result = await scanner.Scan();
if (result != null)
Toast.MakeText(this,"DONE",ToastLength.Short).Show();
};
When I run the application, after pressing the barcodebutton this error log is obtained. What is the error? How can I solve it? :
...
[Mono] Assembly Ref addref ZXing.Net.Mobile[0x784bb038] -> mscorlib[0x777e2a10]: 9
[Mono] Assembly Ref addref TeleLib[0x784b8c58] -> zxing.monoandroid[0x784ba440]: 2
[Mono] The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
[Mono] Unloading image mscorlib.dll [0x78801068].
[Mono] Assembly Ref addref zxing.monoandroid[0x784ba440] -> mscorlib[0x777e2a10]: 10
[Mono] Assembly Ref addref ZXing.Net.Mobile[0x784bb038] -> Mono.Android[0x784bbb98]: 4
[Mono] Assembly Ref addref ZXing.Net.Mobile[0x784bb038] -> zxing.monoandroid[0x784ba440]: 3
[Mono] Assembly Ref addref ZXing.Net.Mobile[0x784bb038] -> Xamarin.Android.Support.v4[0x784b9848]: 2
[Mono] Assembly Ref addref zxing.monoandroid[0x784ba440] -> Mono.Android[0x784bbb98]: 5
[] TypeRef ResolutionScope not yet handled (14) for .CameraInfo in image /data/data/TeleLib.TeleLib/files/.__override__/ZXing.Net.Mobile.dll
[Mono] The class CameraInfo could not be loaded, used in
[MonoDroid] UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'CameraInfo'.
[MonoDroid] at Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder_ (intptr,intptr,intptr) <0x0005f>
[MonoDroid] at (wrapper dynamic-method) object.c17a61df-f7d9-45dc-ba1c-dac5c5d9eb39 (intptr,intptr,intptr) <0x00043>
[mono]
[mono] Unhandled Exception:
[mono] System.TypeLoadException: Could not load type 'CameraInfo'.
[mono] at Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder_ (IntPtr jnienv, IntPtr native__this, IntPtr native_holder) [0x00000] in <filename unknown>:0
[mono] at (wrapper dynamic-method) object:c17a61df-f7d9-45dc-ba1c-dac5c5d9eb39 (intptr,intptr,intptr)
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'CameraInfo'.
[mono-rt] at Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder_ (IntPtr jnienv, IntPtr native__this, IntPtr native_holder) [0x00000] in <filename unknown>:0
[mono-rt] at (wrapper dynamic-method) object:c17a61df-f7d9-45dc-ba1c-dac5c5d9eb39 (intptr,intptr,intptr)
I was running into the same issue and figured out that the ZXing.NET component requires Android version 2.3. Change your project to target 2.3 or newer, and this error will go away.
I'm starting to use mono droid or Xamarin for Android, so, my idea was to reuse most of the code that I already use in .NET.
One of the things I need my android and ios application to do is to make calls to web services made available using wcf rest with json encoding.
So my code is simple:
WebHttpBinding webBinding = new WebHttpBinding();
EndpointAddress endPointAddress = new EndpointAddress("http://192.168.126.24:8025/Services/SecurityManagement");
ChannelFactory<ISecurityManagement> newFactory = new ChannelFactory<ISecurityManagement>(webBinding, endPointAddress);
newFactory.Endpoint.Behaviors.Add(new WebHttpBehavior() { DefaultOutgoingRequestFormat = System.ServiceModel.Web.WebMessageFormat.Json, DefaultOutgoingResponseFormat = System.ServiceModel.Web.WebMessageFormat.Json });
newFactory.Endpoint.Behaviors.Add(new RestEndPointBehavior());
ISecurityManagement newProxy = newFactory.CreateChannel();
ValidateUserExistenceOutput output = newProxy.ValidateUserExistence(new ValidateUserExistenceInput() { Domain = "CRITICAL", Username = "myUserName" });
Simple enough to get me started (at least, that was my idea about mono, make in .net reuse in mono)
But when I run this code I get the following exception exception:
System.NotSupportedException: Loading...
07-25 10:43:40.922 E/mono ( 1950):
07-25 10:43:40.922 E/mono ( 1950): Unhandled Exception:
07-25 10:43:40.922 E/mono ( 1950): System.NotSupportedException: Conversion from the argument parameterType 'BusinessOrchestration.SecurityManagement.InputObjects.ValidateUserExistenceInput' is not supported
07-25 10:43:40.922 E/mono ( 1950): at System.ServiceModel.Dispatcher.QueryStringConverter.ConvertValueToString (System.Object parameter, System.Type parameterType) [0x00000] in <filename unknown>:0
07-25 10:43:40.922 E/mono-rt ( 1950): at System.ServiceModel.Dispatcher.WebMessageFormatter+WebClientMessageFormatter.SerializeRequest (System.ServiceModel.Channels.MessageVersion messageVersion, System.Object[] parameters) [0x00000] in <filename unkno07-25 10:43:40.922 E/mono ( 1950): at System.ServiceModel.Dispatcher.WebMessageFormatter+WebClientMessageFormatter.SerializeRequest (System.ServiceModel.Channels.MessageVersion messageVersion, System.Object[] parameters) [0x00000] in <filename unknown>:0
07-25 10:43:40.922 E/mono ( 1950): at System.ServiceModel.Description.WebHttpBehavior+ClientPairFormatter.SerializeRequest (System.ServiceModel.Channels.MessageVersion messageVersion, System.Object[] parameters) [0x00000] in <filename unknown>:0
07-25 10:43:40.922 E/mono ( 1950): at System.ServiceModel.MonoInternal.ClientRuntimeChannel.CreateRequest (System.ServiceModel.Dispatcher.ClientOperation op, System.Object[] parameters) [0x00000] in <filename unknown>:0
07-25 10:43:40.922 E/mono ( 1950): at System.ServiceModel.MonoIn
07-25 10:43:40.922 E/mono-rt ( 1950): [ERROR] FATAL UNHANDLED EXCEPTION: System.NotSupportedException: Conversion from the argument parameterType 'BusinessOrchestration.SecurityManagement.InputObjects.ValidateUserExistenceInput' is not supported
07-25 10:43:40.922 E/mono-rt ( 1950): at System.ServiceModel.Dispatcher.QueryStringConverter.ConvertValueToString (System.Object parameter, System.Type parameterType) [0x00000] in <filename unknown>:0
07-25 10:43:40.922 E/mono-rt ( 1950): at System.ServiceModel.Dispatcher.WebMessageFormatter+WebClientMessageFormatter.SerializeRequest (System.ServiceModel.Channels.MessageVersion messageVersion, System.Object[] parameters) [0x00000] in <filename unknown>:0
07-25 10:43:40.922 E/mono-rt ( 1950): at System.ServiceModel.Description.WebHttpBehavior+ClientPairFormatter.SerializeRequest (System.ServiceModel.Channels.MessageVersion messageVersion, System.Object[] parameters) [0x00000] in <filename unknown>:0
07-25 10:43:40.922 E/mono-rt ( 1950): at System.ServiceModel.MonoInternal.ClientRuntimeChannel.CreateRequest (System.ServiceModel.Dispatcher.ClientOperation op, System.Object[] parameters) [0x00000] in <filename unknown>:0
07-25 10:43:40.922 E/mono-rt ( 1950): at System.Servic
The program 'Mono' has exited with code 0 (0x0).
I'm using the exact same code in a .NET 4.5 application and it works fine, it seems that its failing when converting the object to a string (a json string, I suppose).
Should it work directly in mono since it works in .NET?
Do you guys have services with complex input objects?
What api do you use to make these calls?
Thanks ahead for all your help,
Luis Pinho
It doesn't work because some of the object used in your code hasn't been ported to Mono since they are Microsoft specific. There is some information here :
Mono Class Status
For example, this namespace Microsoft.EnterpriseManagement used for ISecurityManagement in your code will probably never be ported.
To work on both Mono or .Net your code must follow the .NET standard. It's a work in progress to harmonize Mono, .Net and .Net Core framework so they could compile common libraries and programs with less code differences.