Sometime startup with nothing but blank screen

#6 · closed · 9 comments

View on GitHub ↗

flypigz

My codes runs fine with the initial version of PaperFoldMenuController, but after replaced with the latest version, sometime it startup with nothing but blank screen. When I try to pause this app in Xcode debug window, it show that the callstack: semaphore_wait_trap NSOperation start PaperFoldMenuController viewDidLoad I guess this is because the viewDidLoadBlockOperation, which is newly introduced.

Comments

honcheng

Hi flypigz, Thanks. I'll check with the contributor what that does. On 26 Nov, 2012 2:17 AM, flypigz wrote:

honcheng

Are you using code or IB?

lxcid

Hi flypigz, That was a code I introduced, it was meant to defer the setting of `selectedIndex` until viewDidLoad. Could you share how you initialise the PaperFoldVC code? Its weird that it got stuck there. I knew that this is running on a separate thread but on my test it doesn't seems to cause issue. I'll try to send a fix for that today that make it run on the current thread.

flypigz

I tried the demo many times, there is no such issue, I am not sure if this is because the demo view controller is too simple, and nothing to load. Pure code, no IB. Here are my init codes. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. // custom initialization [self setupDatabase]; [self applyStylesheet]; [self appStartup]; self.window.backgroundColor = [UIColor blackColor]; [self.window makeKeyAndVisible]; return YES; } #pragma mark #pragma mark - Application's Startup /////////////////////////////////////////////////////////////////////////////////////////////////// - (void)appStartup { _menuController = [[MenuViewController alloc] initWithMenuWidth:200.0 numberOfFolds:3]; [self.window setRootViewController:_menuController]; StartupViewController *startupVC = [[StartupViewController alloc] init]; UINavigationController *startupNav = [[UINavigationController alloc] initWithRootViewController:startupVC]; ThemesSettingViewController *themesVC = [[ThemesSettingViewController alloc] init]; UINavigationController *themesNav = [[UINavigationController alloc] initWithRootViewController:themesVC]; SettingsViewController *settingsVC = [[SettingsViewController alloc] init]; UINavigationController *settingsNav = [[UINavigationController alloc] initWithRootViewController:settingsVC]; HelpViewController *helpVC = [[HelpViewController alloc] init]; UINavigationController *helpNAV = [[UINavigationController alloc] initWithRootViewController:helpVC]; NSMutableArray *viewControllers = [NSMutableArray arrayWithObjects:startupNav, themesNav, settingsNav, helpNAV, nil]; [_menuController setViewControllers:viewControllers]; }

lxcid

Give me about an hour. I made a minor change to the way I handles deferring of setting selected Index and see if it helps. :) Cheers! ## Stan Chang Khin Boon Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Monday, 26 November, 2012 at 11:06 AM, flypigz wrote: > I tried the demo many times, there is no such issue, I am not sure if this is because the demo view controller is too simple, and nothing to load. > Pure code, no IB. Here are my init codes. > (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions > { > self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; > // Override point for customization after application launch. > // custom initialization > [self setupDatabase]; > [self applyStylesheet]; > [self appStartup]; > self.window.backgroundColor = [UIColor blackColor]; > [self.window makeKeyAndVisible]; > return YES; > } > #pragma mark > #pragma mark - Application's Startup > /////////////////////////////////////////////////////////////////////////////////////////////////// > (void)appStartup { > _menuController = [[MenuViewController alloc] initWithMenuWidth:200.0 numberOfFolds:3]; > [self.window setRootViewController:_menuController]; > StartupViewController *startupVC = [[StartupViewController alloc] init]; > UINavigationController *startupNav = [[UINavigationController alloc] initWithRootViewController:startupVC]; > ThemesSettingViewController *themesVC = [[ThemesSettingViewController alloc] init]; > UINavigationController *themesNav = [[UINavigationController alloc] initWithRootViewController:themesVC]; > SettingsViewController *settingsVC = [[SettingsViewController alloc] init]; > UINavigationController *settingsNav = [[UINavigationController alloc] initWithRootViewController:settingsVC]; > HelpViewController *helpVC = [[HelpViewController alloc] init]; > UINavigationController *helpNAV = [[UINavigationController alloc] initWithRootViewController:helpVC]; > NSMutableArray *viewControllers = [NSMutableArray arrayWithObjects:startupNav, themesNav, settingsNav, helpNAV, nil]; > [_menuController setViewControllers:viewControllers]; > } > > — > Reply to this email directly or view it on GitHub (https://github.com/honcheng/PaperFoldMenuController/issues/6#issuecomment-10703082).

flypigz

Hi, lxcid, I think it is a good idea to let all init stuffs run on the current thread, I don't know the reason but I guess this should be the root cause.....Thank you. Actually the initial version works fine, the only “issue” is that it do some view creation stuffs in the "- (id)initWithMenuWidth:(float)menuWidth numberOfFolds:(int)numberOfFolds" method. It is not elegant but it works.

lxcid

Yeah, I agree that I should not let init stuff run on main thread. I was using the `NSOperation addExecutionBlock`. It was spinning threads if I use that method. I planning to just keep an array of blocks instead. Cheers!

lxcid

Hi flypigz, Could you try my latest pull request and see if it works for you?

flypigz

Hi, Lxcid and HonCheng, :-) Works like a charm! Cheers! Thank you for your quick fix!!