输入文本时,带有 RefreshRequested 和 EntryElement 的 DialogViewController 崩溃 [英] A DialogViewController with RefreshRequested and EntryElement crash when text entered

查看:20
本文介绍了输入文本时,带有 RefreshRequested 和 EntryElement 的 DialogViewController 崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DialogViewController 包含一个 EntryElement 和 RefreshRequested 处理程序(见下面的代码).在模拟器中运行,调试模式,在 EntryElement 中键入一些快速随机文本(包含空格).崩溃将随之而来.

我做错了什么?

我猜这是 DialogViewController 中的一个错误,没有保留一些被垃圾收集的图像.是否有跟踪垃圾收集器和已删除对象的开关?

违规代码:

[注册(AppDelegate")]公共部分类 AppDelegate : UIApplicationDelegate{//类级声明UIWindow 窗口;UINavigationController navController;DialogViewController dv ;public override bool FinishedLaunching (UIApplication app, NSDictionary options){//根据屏幕大小创建一个新的窗口实例window = new UIWindow (UIScreen.MainScreen.Bounds);navController = new UINavigationController();var root = new RootElement("测试") {new Section("快速输入一些文本") {new EntryElement("包含空格", string.Empty, string.Empty)}};dv = new DialogViewController(root, true);dv.RefreshRequested += HandleDvRefreshRequested;//注释此行修复了错误window.MakeKeyAndVisible();如果 (UIDevice.CurrentDevice.CheckSystemVersion (5, 0)) {window.RootViewController = navController;} 别的 {window.AddSubview (navController.View);}返回真;}void HandleDvRefreshRequested(对象发送者,EventArgs e){dv.ReloadComplete();}}

<前>启动 iOS 模拟器 5.0启动应用程序应用程序启动.PID = 4730加载的程序集:/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll [外部]加载的程序集:/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll [外部]加载的程序集:/Developer/MonoTouch/usr/lib/mono/2.1/System.dll [外部]话题开始:加载的程序集:/Users/user/Documents/iphone-cinetoile/Cinetoile.UI2/bin/iPhoneSimulator/Debug/MyApp.exe加载的程序集:/Developer/MonoTouch/usr/lib/mono/2.1/MonoTouch.Dialog-1.dll [外部]加载的程序集:/Developer/MonoTouch/usr/lib/mono/2.1/Mono.Security.dll [外部]加载的程序集:/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll [外部]堆栈跟踪:at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr)在 MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00042] in/Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29在 MyApp.Application.Main (string[]) [0x00000] 在/Users/user/Documents/MyApp/Main.cs:17at (wrapper runtime-invoke) .runtime_invoke_void_object (object,intptr,intptr,intptr)

本机堆栈跟踪:

0 MyApp 0x000908ec mono_handle_native_sigsegv + 2841 我的应用程序 0x00005c88 mono_sigsegv_signal_handler + 2482 libSystem.B.dylib 0x9141905b _sigtramp + 433 ???0xffffffff 0x0 + 42949672954 ???0x92c013ef 0x0 + 24620615515 ???0x92c011ee 0x0 + 24620610386 ???0x987a313c 0x0 + 25581448287 CoreGraphics 0x91b49e20 CGDataProviderRetain + 228 ???0x9880c456 0x0 + 25585757029 ImageIO 0x9754a0d2 CGImageReadCreateWithProvider + 18510 ImageIO 0x97549fee CGImageSourceCreateWithDataProvider + 18611 核心图形 0x013c0d2f CGImageCreateWithPNGDataProvider + 8712 WebCore 0x073ca2a5 WKGraphicsCreateImageFromBundleWithName + 37313 WebCore 0x06c1c5bd _ZN7WebCore15GraphicsContext23drawLineForTextCheckingERKNS_10FloatPointEfNS0_21TextCheckingLineStyleE + 36914 WebCore 0x06cf6e84 _ZN7WebCore13InlineTextBox28paintSpellingOrGrammarMarkerEPNS_15GraphicsContextERKNS_10FloatPointERKNS_14DocumentMarkerEPNS_11RenderStyleERKNS_4FontEb + 168415 WebCore 0x06cf6fb9 _ZN7WebCore13InlineTextBox20paintDocumentMarkersEPNS_15GraphicsContextERKNS_10FloatPointEPNS_11RenderStyleERKNS_4FontEb + 29716 WebCore 0x06cf33fc _ZN7WebCore13InlineTextBox5paintERNS_9PaintInfoEiiii + 649017 WebCore 0x06cec3cd _ZN7WebCore13InlineFlowBox5paintERNS_9PaintInfoEiiii + 106518 WebCore 0x0724d24c _ZN7WebCore13RootInlineBox5paintERNS_9PaintInfoEiiii + 6419 WebCore 0x071a8e2a _ZNK7WebCore17RenderLineBoxList5paintEPNS_20RenderBoxModelObjectERNS_9PaintInfoEii + 63820 WebCore 0x07142089 _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii + 36921 WebCore 0x0714248f _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii + 30722 WebCore 0x07141615 _ZN7WebCore11RenderBlock13paintChildrenERNS_9PaintInfoEii + 46723 WebCore 0x071420ab _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii + 40324 WebCore 0x0714248f _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii + 30725 WebCore 0x07141615 _ZN7WebCore11RenderBlock13paintChildrenERNS_9PaintInfoEii + 46726 WebCore 0x071420ab _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii + 40327 WebCore 0x0714248f _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii + 30728 WebCore 0x07141615 _ZN7WebCore11RenderBlock13paintChildrenERNS_9PaintInfoEii + 46729 WebCore 0x071420ab _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii + 40330 WebCore 0x0714248f _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii + 30731 网络核心 0x071961b0 _ZN7WebCore11RenderLayer10paintLayerEPS0_PNS_15GraphicsContextERKNS_7IntRectEjPNS_12RenderObjectEPN3WTF7HashMapIPNS_24OverlapTestRequestClientES4_NS9_7PtrHashISC_EENSTraEEJISC3EENSTraEEJISC3EENSTraEEJ8ISC_15GraphicsContextERKNS_7IntRectEjPNS_3132 WebCore 0x0719648c _ZN7WebCore11RenderLayer10paintLayerEPS0_PNS_15GraphicsContextERKNS_7IntRectEjPNS_12RenderObjectEPN3WTF7HashMapIPNS_24OverlapTestRequestClientES4_NS9_7PtrHashISC_EENSTraEEJISC_EENSTraEEJISC1033 WebCore 0x071973bb _ZN7WebCore11RenderLayer5paintEPNS_15GraphicsContextERKNS_7IntRectEjPNS_12RenderObjectE + 10134 WebCore 0x06bef809 _ZN7WebCore9FrameView13paintContentsEPNS_15GraphicsContextERKNS_7IntRectE + 59135 WebKit 0x067a51d0 -[WebFrame(WebInternal)_drawRect:contentsOnly:] + 36836 WebKit 0x067cc83c -[WebHTMLView drawSingleRect:] + 12437 WebKit 0x067cc786 -[WebHTMLView drawRect:] + 11838 WebCore 0x07392c2f _ZL12drawCallbackP6WKView6CGRectPv + 9539 WebCore 0x073cd52c _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 49240 WebCore 0x073cd61f _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 73541 WebCore 0x073cd61f _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 73542 WebCore 0x073cd61f _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 73543 WebCore 0x073cd61f _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 73544 WebCore 0x073cd80e WKViewDisplayRect + 15845 WebCore 0x073cead0 WKWindowDrawRect + 4846 WebCore 0x0735daf0 _ZN7WebCore9TileCache9drawLayerEP9TileLayerP9CGContext + 88047 WebCore 0x07362af1 -[TileLayer drawInContext:] + 4948 QuartzCore 0x0417212d _ZL16backing_callbackP9CGContextPv + 8849 QuartzCore 0x0409215d CABackingStoreUpdate_ + 263650 QuartzCore 0x04171fd2 _ZN2CA5Layer8display_Ev + 137051 QuartzCore 0x0415fcf1 -[CALayer _display] + 3352 QuartzCore 0x04166281 _ZN2CA5Layer7displayEv + 16553 QuartzCore 0x0415fd17 -[CALayer display] + 3354 QuartzCore 0x04169c5c _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 25655 QuartzCore 0x040effb9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 39556 QuartzCore 0x040f1ea6 _ZN2CA11Transaction6commitEv + 37457 QuartzCore 0x040f1580 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 8058 CoreFoundation 0x011959ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 3059 核心基金会 0x0112c670 __CFRunLoopDoObservers + 38460 核心基金会 0x010f84f6 __CFRunLoopRun + 117461 核心基金会 0x010f7db4 CFRunLoopRunSpecific + 21262 核心基金会 0x010f7ccb CFRunLoopRunInMode + 12363 图形服务 0x04789879 GSEventRunModal + 20764 图形服务 0x0478993e GSEventRun + 11465 UIKit 0x02190a9b UIApplicationMain + 117566 ???0x0cda47fd 0x0 + 21563186967 ???0x0cc78ea0 0x0 + 21440476868 ???0x0cc78b98 0x0 + 21440399269 ???0x0cc78cee 0x0 + 21440433470 我的应用程序 0x00009ff2 mono_jit_runtime_invoke + 72271 我的应用程序 0x00169eee mono_runtime_invoke + 12672 我的应用程序 0x0016dfd4 mono_runtime_exec_main + 42073 我的应用程序 0x001733f5 mono_runtime_run_main + 72574 我的应用程序 0x000671f5 mono_jit_exec + 14975 我的应用程序 0x002116c9 主 + 282576 我的应用程序 0x00003045 开始 + 53

<前>==================================================================执行本机代码时收到 SIGSEGV.这通常表明单声道运行时或本机库之一中的致命错误由您的应用程序使用.==================================================================

解决方案

这是一个 Autocorrection 反击,也就是 bug #325(还有很多重复),它是 不是 MonoTouch 具体.

在内心深处,模拟的 iOS 已损坏并显示出来,而它想绘制它的小红线以显示某些内容拼写错误.

这将发生在模拟器中,并且仅当 UITextField 启用了自动更正时才会发生.像这样关闭它:

new EntryElement("包含空格", string.Empty, string.Empty) {AutocorrectionType = UITextAutocorrectionType.No}

将解决该问题(并且您只能为使用 #define 的模拟器构建执行此操作).

A DialogViewController contains an EntryElement and RefreshRequested handler is set (see code below). Run in the simulator, debug mode, type some quick random text (containing spaces) in the EntryElement. Crash will follow.

What I am doing wrong ?

I guess this is a bug in DialogViewController not retaining some images that is garbage collected. Is there a switch to trace garbage collector and removed objects ?

the offending code :

[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
    // class-level declarations
    UIWindow window;
    UINavigationController navController;
    DialogViewController dv ;


    public override bool FinishedLaunching (UIApplication app, NSDictionary options)
    {
        // create a new window instance based on the screen size
        window = new UIWindow (UIScreen.MainScreen.Bounds);

        navController = new UINavigationController();
        var root = new RootElement("Test") {
            new Section("Quick type some text") {
                new EntryElement("that contains spaces", string.Empty, string.Empty)
            }
        };

        dv = new DialogViewController(root, true);
        dv.RefreshRequested += HandleDvRefreshRequested; // comment this line fixes the bug
        window.MakeKeyAndVisible ();


        if (UIDevice.CurrentDevice.CheckSystemVersion (5, 0)) {
            window.RootViewController = navController;
        } else {
            window.AddSubview (navController.View);
        }

        return true;
    }

    void HandleDvRefreshRequested (object sender, EventArgs e)
    {
       dv.ReloadComplete();
    }
}


   Starting iOS simulator 5.0
   Launching application
   Application launched. PID = 4730
   Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll [External]
   Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll [External]
   Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.dll [External]
   Thread started: 
   Loaded assembly: /Users/user/Documents/iphone-cinetoile/Cinetoile.UI2/bin/iPhoneSimulator/Debug/MyApp.exe
   Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/MonoTouch.Dialog-1.dll [External]
   Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/Mono.Security.dll [External]
   Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll [External]

Stacktrace:

  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) 
  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
  at MyApp.Application.Main (string[]) [0x00000] in /Users/user/Documents/MyApp/Main.cs:17
  at (wrapper runtime-invoke) .runtime_invoke_void_object (object,intptr,intptr,intptr) 

Native stacktrace:

0   MyApp                               0x000908ec mono_handle_native_sigsegv + 284
1   MyApp                               0x00005c88 mono_sigsegv_signal_handler + 248
2   libSystem.B.dylib                   0x9141905b _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   ???                                 0x92c013ef 0x0 + 2462061551
5   ???                                 0x92c011ee 0x0 + 2462061038
6   ???                                 0x987a313c 0x0 + 2558144828
7   CoreGraphics                        0x91b49e20 CGDataProviderRetain + 22
8   ???                                 0x9880c456 0x0 + 2558575702
9   ImageIO                             0x9754a0d2 CGImageReadCreateWithProvider + 185
10  ImageIO                             0x97549fee CGImageSourceCreateWithDataProvider + 186
11  CoreGraphics                        0x013c0d2f CGImageCreateWithPNGDataProvider + 87
12  WebCore                             0x073ca2a5 WKGraphicsCreateImageFromBundleWithName + 373
13  WebCore                             0x06c1c5bd _ZN7WebCore15GraphicsContext23drawLineForTextCheckingERKNS_10FloatPointEfNS0_21TextCheckingLineStyleE + 369
14  WebCore                             0x06cf6e84 _ZN7WebCore13InlineTextBox28paintSpellingOrGrammarMarkerEPNS_15GraphicsContextERKNS_10FloatPointERKNS_14DocumentMarkerEPNS_11RenderStyleERKNS_4FontEb + 1684
15  WebCore                             0x06cf6fb9 _ZN7WebCore13InlineTextBox20paintDocumentMarkersEPNS_15GraphicsContextERKNS_10FloatPointEPNS_11RenderStyleERKNS_4FontEb + 297
16  WebCore                             0x06cf33fc _ZN7WebCore13InlineTextBox5paintERNS_9PaintInfoEiiii + 6490
17  WebCore                             0x06cec3cd _ZN7WebCore13InlineFlowBox5paintERNS_9PaintInfoEiiii + 1065
18  WebCore                             0x0724d24c _ZN7WebCore13RootInlineBox5paintERNS_9PaintInfoEiiii + 64
19  WebCore                             0x071a8e2a _ZNK7WebCore17RenderLineBoxList5paintEPNS_20RenderBoxModelObjectERNS_9PaintInfoEii + 638
20  WebCore                             0x07142089 _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii + 369
21  WebCore                             0x0714248f _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii + 307
22  WebCore                             0x07141615 _ZN7WebCore11RenderBlock13paintChildrenERNS_9PaintInfoEii + 467
23  WebCore                             0x071420ab _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii + 403
24  WebCore                             0x0714248f _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii + 307
25  WebCore                             0x07141615 _ZN7WebCore11RenderBlock13paintChildrenERNS_9PaintInfoEii + 467
26  WebCore                             0x071420ab _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii + 403
27  WebCore                             0x0714248f _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii + 307
28  WebCore                             0x07141615 _ZN7WebCore11RenderBlock13paintChildrenERNS_9PaintInfoEii + 467
29  WebCore                             0x071420ab _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoEii + 403
30  WebCore                             0x0714248f _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoEii + 307
31  WebCore                             0x071961b0 _ZN7WebCore11RenderLayer10paintLayerEPS0_PNS_15GraphicsContextERKNS_7IntRectEjPNS_12RenderObjectEPN3WTF7HashMapIPNS_24OverlapTestRequestClientES4_NS9_7PtrHashISC_EENS9_10HashTraitsISC_EENSF_IS4_EEEEj + 3684
32  WebCore                             0x0719648c _ZN7WebCore11RenderLayer10paintLayerEPS0_PNS_15GraphicsContextERKNS_7IntRectEjPNS_12RenderObjectEPN3WTF7HashMapIPNS_24OverlapTestRequestClientES4_NS9_7PtrHashISC_EENS9_10HashTraitsISC_EENSF_IS4_EEEEj + 4416
33  WebCore                             0x071973bb _ZN7WebCore11RenderLayer5paintEPNS_15GraphicsContextERKNS_7IntRectEjPNS_12RenderObjectE + 101
34  WebCore                             0x06bef809 _ZN7WebCore9FrameView13paintContentsEPNS_15GraphicsContextERKNS_7IntRectE + 591
35  WebKit                              0x067a51d0 -[WebFrame(WebInternal) _drawRect:contentsOnly:] + 368
36  WebKit                              0x067cc83c -[WebHTMLView drawSingleRect:] + 124
37  WebKit                              0x067cc786 -[WebHTMLView drawRect:] + 118
38  WebCore                             0x07392c2f _ZL12drawCallbackP6WKView6CGRectPv + 95
39  WebCore                             0x073cd52c _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 492
40  WebCore                             0x073cd61f _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 735
41  WebCore                             0x073cd61f _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 735
42  WebCore                             0x073cd61f _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 735
43  WebCore                             0x073cd61f _ZL11_WKViewDrawP9CGContextP6WKView6CGRectb + 735
44  WebCore                             0x073cd80e WKViewDisplayRect + 158
45  WebCore                             0x073cead0 WKWindowDrawRect + 48
46  WebCore                             0x0735daf0 _ZN7WebCore9TileCache9drawLayerEP9TileLayerP9CGContext + 880
47  WebCore                             0x07362af1 -[TileLayer drawInContext:] + 49
48  QuartzCore                          0x0417212d _ZL16backing_callbackP9CGContextPv + 88
49  QuartzCore                          0x0409215d CABackingStoreUpdate_ + 2636
50  QuartzCore                          0x04171fd2 _ZN2CA5Layer8display_Ev + 1370
51  QuartzCore                          0x0415fcf1 -[CALayer _display] + 33
52  QuartzCore                          0x04166281 _ZN2CA5Layer7displayEv + 165
53  QuartzCore                          0x0415fd17 -[CALayer display] + 33
54  QuartzCore                          0x04169c5c _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 256
55  QuartzCore                          0x040effb9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 395
56  QuartzCore                          0x040f1ea6 _ZN2CA11Transaction6commitEv + 374
57  QuartzCore                          0x040f1580 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 80
58  CoreFoundation                      0x011959ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
59  CoreFoundation                      0x0112c670 __CFRunLoopDoObservers + 384
60  CoreFoundation                      0x010f84f6 __CFRunLoopRun + 1174
61  CoreFoundation                      0x010f7db4 CFRunLoopRunSpecific + 212
62  CoreFoundation                      0x010f7ccb CFRunLoopRunInMode + 123
63  GraphicsServices                    0x04789879 GSEventRunModal + 207
64  GraphicsServices                    0x0478993e GSEventRun + 114
65  UIKit                               0x02190a9b UIApplicationMain + 1175
66  ???                                 0x0cda47fd 0x0 + 215631869
67  ???                                 0x0cc78ea0 0x0 + 214404768
68  ???                                 0x0cc78b98 0x0 + 214403992
69  ???                                 0x0cc78cee 0x0 + 214404334
70  MyApp                               0x00009ff2 mono_jit_runtime_invoke + 722
71  MyApp                               0x00169eee mono_runtime_invoke + 126
72  MyApp                               0x0016dfd4 mono_runtime_exec_main + 420
73  MyApp                               0x001733f5 mono_runtime_run_main + 725
74  MyApp                               0x000671f5 mono_jit_exec + 149
75  MyApp                               0x002116c9 main + 2825
76  MyApp                               0x00003045 start + 53


   =================================================================
   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.
   =================================================================

解决方案

It's a case of Autocorrection strikes back, aka bug #325 (and quite a few duplicates) and it's not MonoTouch specific.

Something, deep down, the simulated iOS gets corrupted and shows up while it wants to draw it's little red line to show something is misspelled.

This will only happen in the simulator and only when an UITextField has auto-correction enabled. Turning it off like this:

new EntryElement("that contains spaces", string.Empty, string.Empty) {
    AutocorrectionType = UITextAutocorrectionType.No
}

will solve the issue (and you can do it only for your simulator builds with a #define).

这篇关于输入文本时,带有 RefreshRequested 和 EntryElement 的 DialogViewController 崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆