-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash using TyphoonFactoryProvider using Xcode 5.1 after building for Release #200
Comments
@jervine10 Sorry to hear that you're having trouble. @drodriguez Can you take a look? Meantime Typhoon now allows using the assembly interface itself as a factory. Here's an example: - (id)couponListControllerWithStore:(VBStore*)store category:(NSString*)category;
{
return [TyphoonDefinition withClass:[VBCouponListViewController class] initialization:^(TyphoonInitializer* initializer)
{
initializer.selector = @selector(initWithCouponDao:couponListView:store:category:);
[initializer injectParameterWith:[_persistenceComponents couponDao]];
[initializer injectParameterWith:[self couponListView]];
[initializer injectParameterWith:store];
[initializer injectParameterWith:category];
} properties:^(TyphoonDefinition* definition)
{
definition.scope = TyphoonScopePrototype;
}];
} |
@jasperblues that is right, but
|
I forgot to mention that this crash only occurs when running on a device. The simulator works fine. |
@jervine10 That's not unusual for a memory related bug. Thanks for letting us know - will help to reproduce. . . speaking of that, is there any chance you could submit a failing test or project that shows the problem? This will help to resolve this issue more quickly. |
I linked out to a project that you can download. Where can I submit one? |
@jervine10 Please send it to [email protected] |
Thanks guys, I sent out the project. |
@jervine10 I saw your project linked at first message.
- (id)carViewControllerWithNumberOfWeels:(NSNumber *)numberOfWeels
{
return [TyphoonDefinition withClass:[CarViewController class] injections:^(TyphoonDefinition *definition) {
[definition injectInitializer:@selector(initWithNumberOfWheels:make:) withParameters:^(TyphoonMethod *initializer) {
[initializer injectParameterWith:numberOfWeels];
[initializer injectParameterWith:@"Ford"];
}];
}];
}
@interface ToolsCrasherDataSource : NSObject <ToolsCrasherViewControllerDataSource>
@property (nonatomic, strong) ToolsCrasherAssembly *assembly;
@end
[self.assembly carViewControllerWithNumberOfWeels:@(index)] Hope that helps, will be glad to any feedback. |
I will try to have a look at the project from the top of the thread in a couple of hours. One question @jervine10: you say “crashes here because self and toolsCrasherViewController is nil”. Is “self” the instance of |
That can be because you run debug console on release configuration. Release configuration haven't debug information and symbols. Don't trust that you see in console when run on release - it is time when 2+2=nil or something else :-) |
To be sure, try to print |
@drodriguez When this happens, another factory is invoked and a few other objects are created. This factory does not blow up. The difference between the factory that does work and the factory that does not work is in the assembly definition. In the successful factory, I provide my own factoryMethods in the assembly, in the unsuccessful I let Typhoon do its magic for me. So out of my 4 factories, the app crashes on all of them except for the one where I provide the factoryMethod bodies myself. Here's a snippet of some of my definitions: Fails: - (id)weatherStripViewControllerFactory {
return [TyphoonFactoryProvider withProtocol:@protocol(AWWeatherStripViewControllerFactory) dependencies:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(stripViewCellViewControllerFactory) withDefinition:[self stripViewCellViewControllerFactory]];
[definition injectProperty:@selector(animationViewController) withDefinition:[self.navigationAssembly animationViewController]];
[definition injectProperty:@selector(pullToRefreshGestureHandler) withDefinition:[self.navigationAssembly pullToRefreshGestureHandler]];
[definition injectProperty:@selector(scrollListenerController) withDefinition:[self.necessaryEvilsAssembly weatherStripViewControllerScrollListener]];
[definition injectProperty:@selector(stripViewController) withDefinition:[self verticalStripViewController]];
} returns:[AWWeatherStripViewController class]];
} Successful: - (id)stripViewCellViewControllerFactory {
return [TyphoonFactoryProvider withProtocol:@protocol(AWStripViewCellViewControllerFactory) dependencies:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(refreshDelegate) withDefinition:[self.navigationAssembly refreshController]];
[definition injectProperty:@selector(presentationController) withDefinition:[self.navigationAssembly presentationController]];
} factories:^(TyphoonAssistedFactoryDefinition *definition) {
[definition factoryMethod:@selector(landingScreenViewControllerWithUserLocation:resizeDelegate:)
body:^id (TyphoonAssistedFactoryBase<AWStripViewCellViewControllerFactory> *factory,
AWUserLocation *userLocation,
id<AWResizableViewControllerDelegate> resizeDelegate) {
id componentFactory = factory.componentFactory;
id<AWDailyDetailsPagingViewControllerFactory> dailyDetailsPagingViewControllerFactory = [componentFactory dailyDetailsPagingViewControllerFactory];
return [[AWLandingScreenViewController alloc] initWithResizeDelegate:resizeDelegate
presentationController:factory.presentationController
refreshDelegate:factory.refreshDelegate
userLocation:userLocation
dailyDetailsPagingViewControllerFactory:dailyDetailsPagingViewControllerFactory];
}];
}];
} |
@alexgarbarev |
Alright, so I updated all of my factory definitions to provide method bodies manually and everything is working as expected again. Is this issue affecting everyone who is using FactoryProviders without providing any custom method bodies through the |
@jervine10, can you try the diff at https://gist.github.com/drodriguez/970cdcb0517b4fdfc954 and tell me if that works in your real project? I cannot understand why it was working and no longer works, but that seems to stop the crashing. |
@drodriguez |
I will apply the change to the master branch. Until we release the next version you must use the Thanks for the help and the minimal example. It would have been impossible or very difficult without those. |
Compiling with Xcode 5.1, with Release configuration and running on the device, it seems that the returned value was invalid when reaching user code, and caused crashes. See appsquickly#200.
Closing. |
This is an incredibly odd scenario. Our team has spent the better part of two days tracking this issue down. We've recently upgrade to Xcode 5.1 which came out March 10th. Any time we build and run the app in Debug mode all is well. However, as soon as we Archive the app using the Release build configuration and install on a device we get a continuous crash at launch. We've investigated the crash logs and have found a segmentation fault that is occurring when instantiating a ViewController using Typhoon's FactoryProvider. It's incredibly weird.
We updated our scheme's run configurations to use the Release configuration and installed directly on the device. The exception breakpoint does indeed stop on the line that's using the FactoryProvider. The debug console says that
self
isnil
.... so that's a huge red flag.I'm going to link out to a project that simulates this issue. Keep in mind this is only affected with Xcode version 5.1. Here's the snippet that causes the crash.
NOTE: After downloading the project run
pod install
and open the workspace.The included project is using the latest commit from Typhoon's master branch.
Repo Link: https://github.com/jervine10/ToolsCrash
The text was updated successfully, but these errors were encountered: