appsquickly / typhoon

Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
https://pilgrim.ph
Apache License 2.0
2.7k stars 269 forks source link

Typhoon no longer thread safe again in newest version #521

Closed leimingdu closed 7 years ago

leimingdu commented 8 years ago

Hi,

Currently, I meet a lot of crush by typhoon after I introduce multi-threading in my APP.

Fatal Exception: NSRangeException 0 CoreFoundation 0x1847542d8 exceptionPreprocess 1 libobjc.A.dylib 0x195f280e4 objc_exception_throw 2 CoreFoundation 0x184754218 -[NSException initWithCoder:] 3 Foundation 0x18557379c -[NSString rangeOfString:options:range:locale:] 4 sswdOnline 0x100318d78 -TyphoonTypeDescriptor initWithTypeCode: 5 sswdOnline 0x100318bd4 +TyphoonTypeDescriptor descriptorWithTypeCode: 6 sswdOnline 0x10030fe2c +TyphoonIntrospectionUtils typeForPropertyNamed:inClass: 7 sswdOnline 0x100309a0c -TyphoonFactoryAutoInjectionPostProcessor autoInjectedPropertiesForClass: 8 sswdOnline 0x1003097a8 -TyphoonFactoryAutoInjectionPostProcessor postProcessDefinition: 9 sswdOnline 0x100309730 -TyphoonFactoryAutoInjectionPostProcessor postProcessDefinition:replacement:withFactory: 10 sswdOnline 0x100302f94 -TyphoonComponentFactory definitionAfterApplyingPostProcessorsToDefinition: 11 sswdOnline 0x100302e60 __46-[TyphoonComponentFactory applyPostProcessors]_block_invoke (TyphoonComponentFactory.m:349) 12 sswdOnline 0x100302768 -TyphoonComponentFactory enumerateDefinitions: 13 sswdOnline 0x100302e10 -TyphoonComponentFactory applyPostProcessors 14 sswdOnline 0x100302ba8 -TyphoonComponentFactory _load 15 sswdOnline 0x100301f9c -TyphoonComponentFactory load 16 sswdOnline 0x1003024d4 -TyphoonComponentFactory componentForKey:args: 17 CoreFoundation 0x18475a100 _invoking 18 CoreFoundation 0x1846562fc -[NSInvocation invoke] 19 CoreFoundation 0x18465ae30 -[NSInvocation invokeWithTarget:] 20 sswdOnline 0x1002fe290 -TyphoonBlockComponentFactory forwardInvocation: 21 sswdOnline 0x1002f9278 -TyphoonAssembly forwardInvocation:

I saw a similar issue which opened in 2014, in that issue ,it said after upgrade to 2.X the issue will be fixed. However, I am using the newest version which installed using cocospods 3 month ago. After I switch back the single thread, the issue no long obvious. however, such approach have bring a big limitation for my app.

Can you give me some tips how to make typhoon thread safe.

[[[[[UCServiceAssembly assembly] activate] is just the such way to get the instance of assembly.

Thanks in advance

//Leiming

vasilenkoigor commented 8 years ago

Hi @leimingdu!

Can you show code example how do you use assemblies between threads?