Pressing the home button and re-entering with different orientation misaligns current scene on cocos2d-x

I am currently trying to get app rotations working on a cocos2d-x app. I have got it working normally except for one thing. I have ran into a bug where if I press the home button on iOS, rotate the screen, then re-enter the app, the current scene I am looking at will be shrunk on one axis and stretched on another. However, the objects on the screen are touchable at the correct location, not where they appear to be. Upon re-entering
didRotateFromInterfaceOrientation in the RootViewController will be called. This calls this method:

void UIHelper::setScreenForOrientation(bool landscape)
{
    auto director = cocos2d::Director::getInstance();
    auto glview = director->getOpenGLView();
    auto frameSize = glview->getFrameSize();

    Size s;

    if (landscape) {
        s = Size(std::max(frameSize.width, frameSize.height),
                       std::min(frameSize.width, frameSize.height));
    } else {
        s = Size(std::min(frameSize.width, frameSize.height),
                       std::max(frameSize.width, frameSize.height));
    }

    cocos2d::GL::invalidateStateCache();
    cocos2d::GLProgramCache::getInstance()->reloadDefaultGLPrograms();
    cocos2d::DrawPrimitives::init();

    cocos2d::EventCustom recreatedEvent(EVENT_RENDERER_RECREATED);
    director->getEventDispatcher()->dispatchEvent(&recreatedEvent);
    director->setGLDefaultValues();

    glview->setFrameSize(s.width, s.height);
    glview->setDesignResolutionSize(glview->getDesignResolutionSize().width, glview- 
    >getDesignResolutionSize().height, ResolutionPolicy::FIXED_HEIGHT);
    director->drawScene();

    cocos2d::EventCustom orientationChangeEvent(ORIENTATION_CHANGE_EVENT);
    cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&orientationChangeEvent);
}

Here is what it should look like:

,

Here is what it looks like after leaving the app, changing orientation, and re-entering:

,

I did find the issue. The method didRotateFromInterfaceOrientation in the rootViewController is called before applicationWillEnterForeground in the appDelegate. This means that the director’s invalid flag is not set until afterwards. This causes the view to not layout its subviews and as a result causes the shrinking and stretching of the scene after entering the app. To get around this, from the rootViewController, I have made the director call its startAnimation method which sets the valid flag in the director. I then call the layoutSubviews method on the rootViewControllers view. Will there be any unintended side effects to doing this? From the brief testing I have done there doesn’t seem to be any issues. If there is, what should I do instead?