Reputation: 486
I'm trying to create a UIWebView and loading a page. When the loading finishes, I want to move to another screen. The following code works on the iOS simulator, but not on a device. I tried following this answer (Monotouch + UIWebView = Random Crashes), promoting the NSUrlRequest to become a global variable, but the error persists.
I tried using a try{} catch{} but it doesn't grab any exceptions when it crashes. it's driving me insane :)
void LoadSite(){
webView = new UIWebView (new CGRect (0, 0, 300,300));
string url = "http://google.com";
NSUrlRequest request = new NSUrlRequest(new NSUrl(url));
View.AddSubview (webView);
webView.LoadFinished+= (object sender, EventArgs e) => {
// CRASHES
};
webView.LoadRequest(request);
}
Any idea of how to solve this? Thank you.
2015-05-03 19:28:08.465 Baru[5549:638056] critical: Stacktrace:
2015-05-03 19:28:08.466 Baru[5549:638056] critical: at <unknown> <0xffffffff>
2015-05-03 19:28:08.467 Baru[5549:638056] critical: at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSend (intptr,intptr) <0xffffffff>
2015-05-03 19:28:08.469 Baru[5549:638056] critical: at ObjCRuntime.Class.GetClassForObject (intptr) [0x00000] in /Users/builder/data/lanes/1503/6481535e/source/maccore/src/ObjCRuntime/Class.cs:111
2015-05-03 19:28:08.470 Baru[5549:638056] critical: at ObjCRuntime.Runtime.GetNSObject (intptr,System.Type,ObjCRuntime.Runtime/MissingCtorResolution,bool,bool&) [0x00024] in /Users/builder/data/lanes/1503/6481535e/source/maccore/src/ObjCRuntime/Runtime.cs:836
2015-05-03 19:28:08.471 Baru[5549:638056] critical: at ObjCRuntime.Runtime.GetNSObjectWithType (intptr,intptr,bool&) [0x0000c] in /Users/builder/data/lanes/1503/6481535e/source/maccore/src/ObjCRuntime/Runtime.cs:383
2015-05-03 19:28:08.472 Baru[5549:638056] critical: at ObjCRuntime.Runtime.get_nsobject_with_type (intptr,intptr,bool&) [0x00000] in /Users/builder/data/lanes/1503/6481535e/source/maccore/runtime/Delegates.generated.cs:208
2015-05-03 19:28:08.473 Baru[5549:638056] critical: at (wrapper native-to-managed) ObjCRuntime.Runtime.get_nsobject_with_type (intptr,intptr,int&) <0xffffffff>
2015-05-03 19:28:08.473 Baru[5549:638056] critical: at <unknown> <0xffffffff>
2015-05-03 19:28:08.474 Baru[5549:638056] critical: at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0xffffffff>
2015-05-03 19:28:08.475 Baru[5549:638056] critical: at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Users/builder/data/lanes/1503/6481535e/source/maccore/src/UIKit/UIApplication.cs:63
2015-05-03 19:28:08.476 Baru[5549:638056] critical: at UIKit.UIApplication.Main (string[],string,string) [0x0001c] in /Users/builder/data/lanes/1503/6481535e/source/maccore/src/UIKit/UIApplication.cs:46
2015-05-03 19:28:08.476 Baru[5549:638056] critical: at Baru.Application.Main (string[]) [0x00008] in /Users/Montein/Proyectos/BRU/Solution/Baru/Baru/Main.cs:17
2015-05-03 19:28:08.477 Baru[5549:638056] critical: at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>
2015-05-03 19:28:08.478 Baru[5549:638056] critical:
Native stacktrace:
2015-05-03 19:28:08.552 Baru[5549:638056] critical: 0 Baru 0x00000001003ee998 mono_handle_native_sigsegv + 264
2015-05-03 19:28:08.553 Baru[5549:638056] critical: 1 Baru 0x00000001003f8c6c mono_sigsegv_signal_handler + 324
2015-05-03 19:28:08.554 Baru[5549:638056] critical: 2 libsystem_platform.dylib 0x0000000194da495c _sigtramp + 68
2015-05-03 19:28:08.555 Baru[5549:638056] critical: 3 Baru 0x0000000100139a18 wrapper_managed_to_native_ObjCRuntime_Messaging_IntPtr_objc_msgSend_intptr_intptr + 104
2015-05-03 19:28:08.555 Baru[5549:638056] critical: 4 Baru 0x00000001000f9278 ObjCRuntime_Class_GetClassForObject_intptr + 40
2015-05-03 19:28:08.556 Baru[5549:638056] critical: 5 Baru 0x00000001000f17a8 ObjCRuntime_Runtime_GetNSObject_intptr_System_Type_ObjCRuntime_Runtime_MissingCtorResolution_bool_bool_ + 120
2015-05-03 19:28:08.557 Baru[5549:638056] critical: 6 Baru 0x00000001000ef8dc ObjCRuntime_Runtime_GetNSObjectWithType_intptr_intptr_bool_ + 108
2015-05-03 19:28:08.558 Baru[5549:638056] critical: 7 Baru 0x00000001000ede44 ObjCRuntime_Runtime_get_nsobject_with_type_intptr_intptr_bool_ + 36
2015-05-03 19:28:08.558 Baru[5549:638056] critical: 8 Baru 0x0000000100141c48 wrapper_native_to_managed_ObjCRuntime_Runtime_get_nsobject_with_type_intptr_intptr_int_ + 104
2015-05-03 19:28:08.559 Baru[5549:638056] critical: 9 Baru 0x00000001004afb78 xamarin_get_nsobject_with_type + 52
2015-05-03 19:28:08.559 Baru[5549:638056] critical: 10 Baru 0x00000001004afec4 xamarin_get_nsobject_with_type_for_ptr_created + 228
2015-05-03 19:28:08.560 Baru[5549:638056] critical: 11 Baru 0x00000001004b9500 xamarin_trampoline + 3860
2015-05-03 19:28:08.561 Baru[5549:638056] critical: 12 CoreFoundation 0x0000000182d5a100 <redacted> + 144
2015-05-03 19:28:08.561 Baru[5549:638056] critical: 13 CoreFoundation 0x0000000182c562fc <redacted> + 296
2015-05-03 19:28:08.562 Baru[5549:638056] critical: 14 CoreFoundation 0x0000000182c5ae30 <redacted> + 68
2015-05-03 19:28:08.562 Baru[5549:638056] critical: 15 WebKitLegacy 0x00000001924c0898 <redacted> + 172
2015-05-03 19:28:08.562 Baru[5549:638056] critical: 16 CoreFoundation 0x0000000182d57f6c <redacted> + 440
2015-05-03 19:28:08.562 Baru[5549:638056] critical: 17 CoreFoundation 0x0000000182c5accc _CF_forwarding_prep_0 + 92
2015-05-03 19:28:08.563 Baru[5549:638056] critical: 18 CoreFoundation 0x0000000182d5a100 <redacted> + 144
2015-05-03 19:28:08.563 Baru[5549:638056] critical: 19 CoreFoundation 0x0000000182c562fc <redacted> + 296
2015-05-03 19:28:08.563 Baru[5549:638056] critical: 20 WebCore 0x000000019164bda8 <redacted> + 212
2015-05-03 19:28:08.563 Baru[5549:638056] critical: 21 WebKitLegacy 0x00000001924c0650 <redacted> + 128
2015-05-03 19:28:08.563 Baru[5549:638056] critical: 22 WebCore 0x0000000191659414 <redacted> + 84
2015-05-03 19:28:08.564 Baru[5549:638056] critical: 23 WebCore 0x0000000191658790 <redacted> + 812
2015-05-03 19:28:08.564 Baru[5549:638056] critical: 24 WebCore 0x0000000191a6d694 <redacted> + 56
2015-05-03 19:28:08.564 Baru[5549:638056] critical: 25 WebCore 0x0000000191658230 <redacted> + 92
2015-05-03 19:28:08.564 Baru[5549:638056] critical: 26 WebCore 0x0000000191658190 <redacted> + 1588
2015-05-03 19:28:08.564 Baru[5549:638056] critical: 27 WebKitLegacy 0x00000001924d0a34 <redacted> + 228
2015-05-03 19:28:08.564 Baru[5549:638056] critical: 28 CoreFoundation 0x0000000182d5a100 <redacted> + 144
2015-05-03 19:28:08.565 Baru[5549:638056] critical: 29 CoreFoundation 0x0000000182c562fc <redacted> + 296
2015-05-03 19:28:08.565 Baru[5549:638056] critical: 30 CoreFoundation 0x0000000182c5ae30 <redacted> + 68
2015-05-03 19:28:08.565 Baru[5549:638056] critical: 31 WebKitLegacy 0x00000001924c0898 <redacted> + 172
2015-05-03 19:28:08.565 Baru[5549:638056] critical: 32 CoreFoundation 0x0000000182d57f6c <redacted> + 440
2015-05-03 19:28:08.565 Baru[5549:638056] critical: 33 CoreFoundation 0x0000000182c5accc _CF_forwarding_prep_0 + 92
2015-05-03 19:28:08.565 Baru[5549:638056] critical: 34 CoreFoundation 0x0000000182d5a100 <redacted> + 144
2015-05-03 19:28:08.566 Baru[5549:638056] critical: 35 CoreFoundation 0x0000000182c562fc <redacted> + 296
2015-05-03 19:28:08.566 Baru[5549:638056] critical: 36 WebCore 0x0000000191666efc <redacted> + 120
2015-05-03 19:28:08.566 Baru[5549:638056] critical: 37 CoreFoundation 0x0000000182d0c240 <redacted> + 24
2015-05-03 19:28:08.569 Baru[5549:638056] critical: 38 CoreFoundation 0x0000000182d0b4e4 <redacted> + 264
2015-05-03 19:28:08.569 Baru[5549:638056] critical: 39 CoreFoundation 0x0000000182d09594 <redacted> + 712
2015-05-03 19:28:08.569 Baru[5549:638056] critical: 40 CoreFoundation 0x0000000182c352d4 CFRunLoopRunSpecific + 396
2015-05-03 19:28:08.570 Baru[5549:638056] critical: 41 GraphicsServices 0x000000018c44b6fc GSEventRunModal + 168
2015-05-03 19:28:08.570 Baru[5549:638056] critical: 42 UIKit 0x00000001877fafac UIApplicationMain + 1488
2015-05-03 19:28:08.570 Baru[5549:638056] critical: 43 Baru 0x0000000100140d2c wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 348
2015-05-03 19:28:08.571 Baru[5549:638056] critical: 44 Baru 0x000000010010b82c UIKit_UIApplication_Main_string___intptr_intptr + 44
2015-05-03 19:28:08.572 Baru[5549:638056] critical: 45 Baru 0x000000010010b7ec UIKit_UIApplication_Main_string___string_string + 172
2015-05-03 19:28:08.572 Baru[5549:638056] critical: 46 Baru 0x00000001000cc11c Baru_Application_Main_string__ + 156
2015-05-03 19:28:08.573 Baru[5549:638056] critical: 47 Baru 0x0000000100267444 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 180
2015-05-03 19:28:08.573 Baru[5549:638056] critical: 48 Baru 0x00000001003faea4 mono_jit_runtime_invoke + 1260
2015-05-03 19:28:08.573 Baru[5549:638056] critical: 49 Baru 0x0000000100448cc4 mono_runtime_invoke + 128
2015-05-03 19:28:08.574 Baru[5549:638056] critical: 50 Baru 0x000000010044cf50 mono_runtime_exec_main + 404
2015-05-03 19:28:08.574 Baru[5549:638056] critical: 51 Baru 0x00000001004aed8c xamarin_main + 1844
2015-05-03 19:28:08.574 Baru[5549:638056] critical: 52 Baru 0x00000001003515b8 main + 96
2015-05-03 19:28:08.575 Baru[5549:638056] critical: 53 libdyld.dylib 0x0000000194bf6a08 <redacted> + 4
2015-05-03 19:28:08.575 Baru[5549:638056] critical:
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Upvotes: 1
Views: 599
Reputation: 915
It looks good. please refer my code to show progress bar during loading. it may be
1)Please check the internet connection 2)Debug in appdelege more than 12 sec crashes the application
string url = "http://manikandan.azurewebsites.net";
//Web View
webView.ShouldStartLoad += HandleShouldStartLoad;//Handle every url loads in webview
webView.LoadRequest (new NSUrlRequest (new NSUrl (url)));//Load Url in the same view
webView.LoadStarted += ProgressbarLoad;//Show progress bar while loading webview
void ProgressbarLoad (object sender, EventArgs e)
{
// Determine the correct size to start the overlay (depending on device orientation)
var bounds = UIScreen.MainScreen.Bounds; // portrait bounds
if (UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeLeft || UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeRight) {
bounds.Size = new SizeF(bounds.Size.Height, bounds.Size.Width);
}
// show the loading overlay on the UI thread using the correct orientation sizing
this._loadPop = new LoadingOverlay (bounds);
this.View.Add ( this._loadPop );
}
Upvotes: 1