wait_fences:未收到回复:10004003(再次) [英] wait_fences: failed to receive reply: 10004003 (Again)

查看:101
本文介绍了wait_fences:未收到回复:10004003(再次)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

另一个关于这个警告的求助声。



首先,我在其他地方查看了所有问题,似乎没有一个适合我的情况。它与警报框无关,并且作为第一响应者辞职,在视图显示之前也不执行任何动画。实例化基于UIView的自定义键盘时出现问题。



其次,我相信我可以随意显示/消失警告。我只是为什么感到困惑,所以我更多的是寻求解释而不是解决方案。



此处发布的代码太多,所以我只是简要介绍一下发生了什么:


ViewControllerCalc在VC的loadView方法中实例化一个基于UIView的DataView,然后将其添加为VC的子视图。



DataView在DataView的init方法中实例化基于自定义UITextField的TextFieldKPD



TextField实例化基于自定义UIView的KeyPad在TextField的init方法中,将KeyPad分配给TextField的inputView。



KeyPad创建13个类型为UIButtonTypeCustom的UIButtons,读入并指定按下状态每个按钮的未按下图像,以及按钮的设置操作。然后它将每个按钮添加为自身的子视图。 (通过控制在KeyPad的UIView生命周期中发生此构造的时间,我是如何影响wait_fences警告的:见下文。)


CalcViewController是最初呈现给用户的那个。我已经在Calc的viewDidLayoutSubViews方法结束之后和调用viewDidAppear方法之前跟踪了wait_fences警告。请注意,显示Calc时,键盘不可见。



我似乎可以通过更改键盘的构造方式来控制wait_fences警告的操作:




  • 如果UIButtons被实例化并添加为KeyPad的init方法中的子视图,那么我将收到警告,一次和只有一次。


  • 如果按钮被实例化并添加到KeyPad的layoutSubViews方法中,则不会出现警告。 (但是在我点击TextField之前,KeyPad没有有效地构建 - 仍然没有wait_fences警告,然后也是如此)




Calc的loadView中没有动画或任何东西。它是实例化并一直分配。



那么对这个版本的wait_fences有何评论?



编辑1,1月30日 - 现在更加混乱!



I今天早上很无聊所以我决定玩我的代码,看看我是否能更好地隔离警告的产生。我把它缩小到以下,完全无用的代码,我现在可以触发警告:

   - (void)loadImages 
{
UIImage * image;

for(int i = 0; i< 16; i ++){
image = [UIImage imageNamed:@StupidFileNameThatDoesNotExist];
}
}

如果我执行 [self在 KeyPad 的init方法中的loadImages] 然后会出现警告。但是这段代码没有任何作用,因为文件不存在。我相信如果循环计数器足够小以至于警告消失了,但我没有达到下限。



如果我用



替换图像的实际加载量

[UIImage imageWithContentsOfFile: @StupidFileNameThatDoesNotExist]



并在 KeyPad init期间仍调用该方法,然后我似乎没有得到警告。这两种加载图像的方法之间的一个明显区别是 imageNamed 在内部缓存图像。



所以我是倾向于乔治的答案,这是一个内部的苹果搞砸了。



编辑2,2月1日 - 这是一个警告吉姆,但不是我们所知道的



所以我确信自己是UIImage类中的缓存显然导致了这个问题。该怎么办?好吧,当然要编写我自己的图像缓存!!



所以我开始插件,撕掉那些试图加载无效图像的代码并得到了我生成文件的地方我需要的名称,并将它们传递给我的缓存控制器。因此,为了验证事情开始在一起,在缓存控制器中,我为每次缓存图像的尝试生成了一条NSLog消息 - 仅此而已 - 只记录文件名。



猜猜是什么 - 我再次得到了愚蠢的警告。完全没有实际的工作。



我只能得出结论,当我将额外的代码塞进init方法时,我会触发某种内部iOS竞争条件 KeyPad 。并且我无法做任何事情来缓解它。我所能做的就是希望这个警告是良性的。



编辑3,哈姆雷特法案1场景4:丹麦有点腐烂



保留与编辑2中相同的代码,我注释掉了NSLog语句。警告消失了。我把它放回去,然后出现警告。



所以我的代码是:

   - (void)loadImages 
{
//迭代按钮定义并缓存所需图像
for(int i = 0; i< numKeys; i ++){

if(![imageCache imageExistsForTag:keyTags [i]]){
[imageCache addImageFile:[NSString stringWithFormat:@%s_NP.png,keyNames [i]] forTag:keyTags [一世]];
}

if(![imageCache imageExistsForTag:keyTags [i] + pressedOffset]){
[imageCache addImageFile:[NSString stringWithFormat:@%s_P.png,keyNames [i]] forTag:keyTags [i] + pressedOffset];
}

}

}

And:

   - (void)addImageFile:(NSString *)imageFile forTag:(int)tag 
{
NSLog(@添加标签:%d代表文件%@,tag,imageFile);
}

使用NSLog语句控制警告的出现。



编辑4,2月2日 - 欢迎来到末日神殿



将艾伦的评论铭记于心将我的键盘重建为XIB并加载,而不是手动尝试构建视图。当然,这并没有解决任何问题。我原本希望Nib加载会发生在造成问题的范围之外。



我的直觉是我正在抵抗内部的竞争状态Calc的loadView和一些内部iOS活动。如果我在loadView中做了太多工作,那么我越过该行并发出wait_fences警告。键盘是一种症状,而不是根本原因。 IE可能是任何活动,只是键盘工作是警告开始出现之前我做的最后一件事。我只是希望我真的知道我实际穿越的限制是什么,而不是在黑暗中磕磕绊绊。

解决方案

我之前已经有过几次这个问题,并试图找到解决方案。我得到的最接近的是,根据苹果工程师的说法,这是内部引起的问题,第三方开发人员不应该担心它。据我所知,它不应该导致您的应用程序崩溃或导致任何问题,除了调试器中的一个非常恼人的错误似乎驱使所有开发人员疯了!



<抱歉,我无法提供更多帮助。


Another cry for help about this warning.

First of all I have looked at every and all questions on here elsewhere and none seem to fit my situation. It has nothing to do with Alert boxes and resigning as first responder, nor performing any animation before views get displayed. My problem occurs when instantiating a UIView based custom keyboard.

Secondly, I believe that I can make the warning appear/disappear at will. I am just very confused as to why, so I am looking more for an explanation than a solution.

There is too much code to post here, so I'll just give an outline of what is going on:

The ViewController "Calc" instantiates a custom UIView based "DataView" in the VC's loadView method, and then adds it as a sub view of the VC.

The "DataView" instantiates a custom UITextField based "TextFieldKPD" in the DataView's init method

The "TextField" instantiates a custom UIView based "KeyPad" in the TextField's init method, and assigns that KeyPad to the TextField's inputView.

The "KeyPad" creates 13 UIButtons of type UIButtonTypeCustom, reads in and assigns a "pressed" and "not pressed" image for each button, as well as setting actions for the buttons. It then adds each button as a subview of itself. (By controlling when in the UIView lifecycle of the KeyPad that this construction occurs, is how I can effect the wait_fences warning: see below.)

The "Calc" ViewController is the one that is initially presented to the user. I have tracked down the wait_fences warning as occurring after the end of the Calc's viewDidLayoutSubViews method and before its viewDidAppear method is called. Note that the KeyPad is not visible when the Calc is displayed.

I appear to be able to control the action of the wait_fences warning by changing how the Keypad is constructed:

  • If the UIButtons are instantiated and added as subviews in the init method of the KeyPad, then I will get the warning, once and once only.

  • If, instead, the buttons are instantiated and added in the KeyPad's layoutSubViews method, then the warning does not appear. (But the KeyPad doesn't effectively get constructed until I tap on the TextField - still, no wait_fences warning then either)

There is no animation or anything in Calc's loadView. It is instantiate and assign all the way down.

So any comments on this version of wait_fences?

EDIT 1, Jan 30th - Now With Even More Confusion!

I was bored this morning so I decided to play with my code to see if I could better isolate the generation of the warning. I narrowed it down to the following, totally useless code that with which I can now trigger the warning:

-(void)loadImages
{
    UIImage* image;

    for(int i=0; i<16; i++) {
        image = [UIImage imageNamed:@"StupidFileNameThatDoesNotExist"];
    }
}

If I perform [self loadImages] in the init method of KeyPad then the warning appears. But this code does nothing as the file does not exist. I believe that if the loop counter is small enough that the warning does go away, but I haven't qualified a lower limit.

If I replace the actual loading of the image with

[UIImage imageWithContentsOfFile:@"StupidFileNameThatDoesNotExist"]

and still call the method during the KeyPad init, then I do not seem to get the warning. One obvious difference between these two ways of loading the image is that imageNamed caches the image internally.

So I am leaning towards George's answer that it is an internal Apple screw up.

Edit 2, Feb 1 - Its a warning Jim, but not as we know it

So I convinced myself that it was the caching in the UIImage class that was obviously causing the issue. What to do about it? Well write my own image cache of course!!

So I started plugging away, rip out that code that attempted to load invalid images and got the point where I generated the file names I needed and passed them to my cache controller. So to verify that things were starting to come together, within the cache controller, I generated a NSLog message for each attempt to cache an image - nothing more - just log the file name.

And guess what - I get the stupid warning again. For doing no actual work at all.

I can only conclude that there is some sort of internal iOS race condition that I am triggering when I cram extra code into the init method of KeyPad. And that there is nothing I can do to mitigate it. All I can do is hope that this warning is benign.

Edit 3, Hamlet Act 1 scene 4: Something is rotten in the state of Denmark

Keeping the same code as in Edit 2, I commented out the NSLog statement. And the warning went away. I put it back, and the warning appears.

So the code I have is:

-(void)loadImages
{
    // Iterate over button definitions and cache the required images
    for(int i=0; i<numKeys; i++) {

        if (![imageCache imageExistsForTag:keyTags[i]]) {
            [imageCache addImageFile:[NSString stringWithFormat:@"%s_NP.png",keyNames[i]] forTag:keyTags[i]];
        }

        if (![imageCache imageExistsForTag:keyTags[i]+pressedOffset]) {
            [imageCache addImageFile:[NSString stringWithFormat:@"%s_P.png",keyNames[i]] forTag:keyTags[i]+pressedOffset];
        }

    }

}

And:

-(void)addImageFile:(NSString*)imageFile forTag:(int)tag
{
    NSLog(@"Adding tag:%d for file %@", tag, imageFile);
}

With that NSLog statement controlling the appearance of the warning.

Edit 4, Feb 2 - Welcome to the Temple of Doom

Taking Allen's comments to heart I rebuilt my keyboard as a XIB and loaded that instead of manually trying to build the view. Of course that didn't fix anything. I had hoped that the Nib loading would happen outside of what ever it is that is causing the problem.

My gut feeling is that I am butting up against a race condition within the loadView of Calc and some internal iOS activity. If I do too much work inside loadView then I cross the line and trip a wait_fences warning. And that the keyboard is a symptom and not the underlying cause. IE it could have been any activity, it was just that the keyboard work was the last thing I did before the warning started appearing. I just wish that I actually knew what the constraints were that I was actually crossing and not stumbling around in the dark.

解决方案

I've had this issues a few times before and attempted to find a solution. The closest that I got was that according to an apple engineer it is an issue caused internally and 3rd party developers should not worry about it. As far as I am aware it shouldn't cause your app to crash or cause any problems, other than a really annoying error in the debugger that seems to drive all developers mad!

Sorry that I couldn't be of more help.

这篇关于wait_fences:未收到回复:10004003(再次)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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