应用冻结并崩溃与内核恐慌 -

时间:2014-05-15 21:53:33

标签: ios objective-c cocoa-touch core-animation

我有一个应用程序,显示由midi文件播放触发的一些基本动画。它在第一次播放时工作正常,但在后续播放期间冻结。然后,设备通常会重新启动生成崩溃日志,指示发生了内核崩溃。偶尔它会在没有重启的情况下挂起。

动画由一个小的png图像组成,其不透明度从高变低,以产生淡化效果。

冻结发生在[self performSelectorOnMainThread:@selector( setPitch: ) withObject:[NSNumber numberWithInteger:[note intValue]] waitUntilDone:YES];

以下是包含此行的方法:

- (void)log:(NSNotification *)notification {

[NSThread isMainThread];

NSDictionary* info = notification.userInfo;


NSNumber *note;
note = [info objectForKey:kNAMIDI_Note];

BRMidiNoteName *noteConverter = [[BRMidiNoteName alloc] init];

NSString *noteName;
noteName = [noteConverter nameFromNumber:[note intValue] withNotation:[defaults valueForKey:kSettingsNotation]];


[self.currentNoteLabel performSelectorOnMainThread: @selector( setText: ) withObject: noteName waitUntilDone: YES];
[self performSelectorOnMainThread:@selector( setPitch: ) withObject:[NSNumber numberWithInteger:[note intValue]] waitUntilDone:YES];

}


-(void) setPitch:(NSNumber*) pitchValue{

NSInteger visualPitchValue = [pitchValue intValue]- [_currentTrack.trackStartNote intValue] - voiceTransposeValue + 1;

if ([defaults boolForKey:kSettingsVisualiser]) {
    //UIImageView *img = [[UIImageView alloc]init];
    UIImageView *img; 

    if ((visualPitchValue > 0 )) {

        // highlight new pitch
        img = (UIImageView *)[self.view viewWithTag:visualPitchValue];

        if (([pitchValue integerValue] < [currentVoice.bridgeLow integerValue])) {
            [img setImage:[UIImage imageNamed:@"bar_green.png"]];
        }
        else if (([pitchValue integerValue] <= [currentVoice.bridgeHigh integerValue])) {
            [img setImage:[UIImage imageNamed:@"bar_orange"]];
        }
        else{
            [img setImage:[UIImage imageNamed:@"bar_blue.png"]];
        }
        [img setAlpha:1.0];


        // Set up fade out effect
        CABasicAnimation *fadeOutAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
        [fadeOutAnimation setToValue:[NSNumber numberWithFloat:_fadeToOpacity]];
        fadeOutAnimation.fillMode = kCAFillModeForwards;
        fadeOutAnimation.removedOnCompletion = NO;

        CAAnimationGroup *group = [CAAnimationGroup animation];
        group.fillMode = kCAFillModeForwards;
        group.removedOnCompletion = NO;
        // [group setAnimations:[NSArray arrayWithObjects:fadeOutAnimation, pathAnimation, nil]];
        [group setAnimations:[NSArray arrayWithObjects:fadeOutAnimation, nil]];
        group.duration = 0.7f;
        group.delegate = self;
        [group setValue:img forKey:@"imageViewBeingAnimated"];

        [img.layer addAnimation:group forKey:@"savingAnimation"];

    }
}
}

1 个答案:

答案 0 :(得分:0)

我发现将waitUntilDone从YES更改为NO会导致设备屏幕冻结。

[self.currentNoteLabel performSelectorOnMainThread: @selector( setText: ) withObject: noteName waitUntilDone: NO];
[self performSelectorOnMainThread:@selector( setPitch: ) withObject:[NSNumber numberWithInteger:[note intValue]] waitUntilDone:NO];