MaddTheSane / SVGKit

A Cocoa framework for rendering SVG files as Core Animation layers
http://mattrajca.com
Other
47 stars 19 forks source link

Merging back in try/catch around removeObserver from main SVGKit project #18

Closed seltzered closed 9 years ago

seltzered commented 9 years ago

Merging back in try/catch around removeObserver that's similarly in main SVGKit (see https://github.com/SVGKit/SVGKit/blob/2.x/Source/QuartzCore%20additions/SVGKLayer.m#L60-L66 ) . This is a workaround to an exception that gets thrown: "Cannot remove an observer <SVGKLayer 0x608000a68a00> for the key path "showBorder" from <SVGKLayer 0x608000a68a00> because it is not registered as an observer" upon calling removeObserver, even though the init always adds the observer.

I'm trying to investigate this a bit further, but for now the try/catch seems to help avoid an exception from causing a total crash.

Right now I seem to observe this when using SVGKLayer (on it's own, without use of SVKLayeredImage) . I'm still trying to understand why, but I don't observe the issue if I set the layer's action dictionary to a dict of [NSNull null] objects:

NSMutableDictionary *layerActions = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
                                   [NSNull null], @"onOrderIn",
                                   [NSNull null], @"onOrderOut",
                                   [NSNull null], @"sublayers",
                                   [NSNull null], @"contents",
                                   [NSNull null], @"bounds",
                                   [NSNull null], @"position",
                                   [NSNull null], @"hidden",
                                   [NSNull null], @"transform",
                                   nil]; 

of course this effectively disables animation support, so isn't a great workaround.

MaddTheSane commented 9 years ago

IIRC, they're fixing the behavior in iOS 9.

Still, this will make the changes work on older OSes.

seltzered commented 9 years ago

Ah, interesting! For reference, I was encountering this on osx 10.10.4 / 10.10 sdk . Will need to test this on El Capitan eventually.