honcheng / PaperFold-for-iOS

Paper folding animation for iOS
Other
2.7k stars 398 forks source link

EXC_CRASH after resuming from background #2

Closed eliaskg closed 12 years ago

eliaskg commented 12 years ago

Just setting up Paperfold for an app and I recognized a crash appearing after closing the app, opening a few others and reopening the app from background. The app then appears but crashes after a few seconds.

Looking at the logs it seems like there is some problem with [ShadowView drawRect:] but I wasn't able to fix it. Do you have any idea what the problem could be?

MyApp 0x002b834a create_intersected_charset_table (string.c:5413)
MyApp 0x002b37c0 rstr_count (string.c:5492)
MyApp 0x002dbbbe rb_vm_dispatch (dispatcher.cpp:456)
MyApp 0x002fd698 nsstr_forward_m1 (vm.h:681)
MyApp 0x001095fa -[ShadowView drawRect:] + 70
UIKit 0x3600f11c <redacted> + 364
QuartzCore 0x3695f034 <redacted> + 112
QuartzCore 0x3695e770 <redacted> + 1808
QuartzCore 0x3695df44 <redacted> + 980
QuartzCore 0x3695da7a <redacted> + 202
QuartzCore 0x36a319f4 <redacted> + 24
QuartzCore 0x3695d3d2 <redacted> + 238
QuartzCore 0x3695d118 <redacted> + 316
UIKit 0x360ce3f6 <redacted> + 210
UIKit 0x360ce2c6 <redacted> + 10
UIKit 0x360cddac <redacted> + 76
UIKit 0x3600683e <redacted> + 1302
UIKit 0x360061ac <redacted> + 72
UIKit 0x36005b5a <redacted> + 6154
GraphicsServices 0x37d875f2 <redacted> + 590
CoreFoundation 0x34f46142 <redacted> + 14
CoreFoundation 0x34f459a8 <redacted> + 212
CoreFoundation 0x34f446ee <redacted> + 646
CoreFoundation 0x34ec2c1c CFRunLoopRunSpecific + 356
CoreFoundation 0x34ec2aa8 CFRunLoopRunInMode + 104
GraphicsServices 0x37d8633a GSEventRunModal + 74
UIKit 0x3602c534 UIApplicationMain + 1120
MyApp 0x0012b0ea main + 262
MyApp 0x0012ac7b start + 39
honcheng commented 12 years ago

I can't tell from the log. Have to try to reproduce this. Happens consistently, or almost random?

Sent from my iPad

On 27 Jul, 2012, at 10:01 PM, Elias Klughammer reply@reply.github.com wrote:

Just setting up Paperfold for an app and I recognized a crash appearing after closing the app, opening a few others and reopening the app from background. The app then appears but crashes after a few seconds.

Looking at the logs it seems like there is some problem with [ShadowView drawRect:] but I wasn't able to fix it. Do you have any idea what the problem could be?

MyApp 0x002b834a create_intersected_charset_table (string.c:5413)
MyApp 0x002b37c0 rstr_count (string.c:5492)
MyApp 0x002dbbbe rb_vm_dispatch (dispatcher.cpp:456)
MyApp 0x002fd698 nsstr_forward_m1 (vm.h:681)
MyApp 0x001095fa -[ShadowView drawRect:] + 70
UIKit 0x3600f11c <redacted> + 364
QuartzCore 0x3695f034 <redacted> + 112
QuartzCore 0x3695e770 <redacted> + 1808
QuartzCore 0x3695df44 <redacted> + 980
QuartzCore 0x3695da7a <redacted> + 202
QuartzCore 0x36a319f4 <redacted> + 24
QuartzCore 0x3695d3d2 <redacted> + 238
QuartzCore 0x3695d118 <redacted> + 316
UIKit 0x360ce3f6 <redacted> + 210
UIKit 0x360ce2c6 <redacted> + 10
UIKit 0x360cddac <redacted> + 76
UIKit 0x3600683e <redacted> + 1302
UIKit 0x360061ac <redacted> + 72
UIKit 0x36005b5a <redacted> + 6154
GraphicsServices 0x37d875f2 <redacted> + 590
CoreFoundation 0x34f46142 <redacted> + 14
CoreFoundation 0x34f459a8 <redacted> + 212
CoreFoundation 0x34f446ee <redacted> + 646
CoreFoundation 0x34ec2c1c CFRunLoopRunSpecific + 356
CoreFoundation 0x34ec2aa8 CFRunLoopRunInMode + 104
GraphicsServices 0x37d8633a GSEventRunModal + 74
UIKit 0x3602c534 UIApplicationMain + 1120
MyApp 0x0012b0ea main + 262
MyApp 0x0012ac7b start + 39

Reply to this email directly or view it on GitHub: https://github.com/honcheng/PaperFold-for-iOS/issues/2

eliaskg commented 12 years ago

Happens consistently. Tested on iOS 5.1.1 (iPhone 3GS) and iOS 6.0 beta 3 (iPhone 4S).

On 27.07.2012, at 17:13, honcheng wrote:

consistently

eliaskg commented 12 years ago

For your information, when I comment out

- (void) drawRect:(CGRect)rect
{
    if ([self.colorsArray count]>0)
    {
        [self.gradient setColors:self.colorsArray];
    }
}

in ShadowView.m, the issue doesn't occur anymore.

honcheng commented 12 years ago

Maybe I should just change the way I draw the shadow...

Sent from my iPad

On 28 Jul, 2012, at 5:40 PM, Elias Klughammer reply@reply.github.com wrote:

For your information, when I comment out

- (void) drawRect:(CGRect)rect
{
   if ([self.colorsArray count]>0)
   {
       [self.gradient setColors:self.colorsArray];
   }
}

in ShadowView.m, the issue doesn't occur anymore.


Reply to this email directly or view it on GitHub: https://github.com/honcheng/PaperFold-for-iOS/issues/2#issuecomment-7331769

eliaskg commented 12 years ago

I managed to get the shadows working by removing drawRect:and modifying setColorArrays: like this

- (void)setColorArrays:(NSMutableArray*)colors
{
  _colorsArray = [NSMutableArray array];
  for (UIColor *color in colors)
  {
    [self.colorsArray addObject:(id)[color CGColor]];
  }

  [self.gradient setColors:self.colorsArray];
}
honcheng commented 12 years ago

Great!

Did you fork and fix it in your fork? Then I can merge your pull request.

Sent from my iPhone

On 30 Jul, 2012, at 6:39 PM, Elias Klughammer reply@reply.github.com wrote:

I managed to get the shadows working by removing drawRect:and modifying setColorArrays: like this

- (void)setColorArrays:(NSMutableArray*)colors
{
 _colorsArray = [NSMutableArray array];
 for (UIColor *color in colors)
 {
   [self.colorsArray addObject:(id)[color CGColor]];
 }

 [self.gradient setColors:self.colorsArray];
}

Reply to this email directly or view it on GitHub: https://github.com/honcheng/PaperFold-for-iOS/issues/2#issuecomment-7365097

eliaskg commented 12 years ago

Here you go: https://github.com/honcheng/PaperFold-for-iOS/pull/7

honcheng commented 12 years ago

Thanks for fixing the bug. 1st pull request, merged!