0

I work on the iMessage App and stumbled upon this nasty bug. I would really appreciate the power of the community. Did anyone manage to solve it?

  • A clear description of the problem:

I work on a Standalone iMessage App. When the iMessage app is active but hidden below the keyboard tapping on the message from that extension opens an app with an empty screen. Investigation of this problem led me to the conclusion that there is no UIWindow attached to the window property of the view in the MessagesViewController. Also, the MessagesViewController is not displayed in the view hierarchy, and MessagesViewController life cycle methods like viewDidLoad and viewDidAppear are not called.

  • A step-by-step set of instructions to reproduce the problem:
  1. Open an iMessage App (for example Youtube) and send a message from that app to a chat.
  2. Open the iMessage App again
  3. Scroll up so that the iMessage App gets hidden below the keyboard
  4. Scroll down to find a message that you’ve sent in step 1
  5. Tap on the message
  6. The app will expand with an empty view

Here is the bug reproduced in Apple's iMessage Example App https://youtube.com/shorts/3UGyZimctSg?feature=share

Roma Kavinskyi
  • 268
  • 4
  • 12
  • Hi, I can't reproduce your issue. Does it happen with any iMessage app (like youtube) ? If so then it's an iOS or device issue, tell us your device model and iOS version. If it only happen with your app then please post some code. – Damien Oct 09 '22 at 23:09
  • I missed one point in the step-by-step instructions. Added point `2) Open the iMessage App again` The issue is confirmed on the following devices: - iPhone X (iOS 16) - iPhone SE (first generation) (iOS 15.6.1) - iPhone 11 Pro (iOS 15.6.1) - iPhone 11 (iOS 16.0) - iPad Pro 11-inch (iOS 15.6.1) - iPad Pro 9.6-inch (iOS 14.3) – Roma Kavinskyi Oct 10 '22 at 04:45
  • I caught this bug in the following apps: Youtube, ChessME, Tic Tak Toe, and Apple's iMessage Example App – Roma Kavinskyi Oct 10 '22 at 04:56
  • This sounds like a bug, I'd suggest filing an Apple Radar on it. If there is a work-around, you will be given one at that point. – RobMac Oct 16 '22 at 11:51
  • I've already filled out the bug report. However there is one app that doesn't experience this bug for some reason - GamePegion – Roma Kavinskyi Oct 17 '22 at 04:33

1 Answers1

0

I also came across this bug and can reproduce the issue in Apple's sample app as well as every iMessage app on the app store I've tested, except for GamePigeon.

The issue is that the MSMessagesAppViewController's view is not part of any UIWindow hierarchy when you try to reopen the app, but it still has it's parent property. So I came up with this workaround:

override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
    super.didTransition(to: presentationStyle)
    if self.view.window == nil {
        if let parent = self.parent {
            self.view.frame = parent.view.bounds
            parent.view.addSubview(self.view)
        }
    }
}

Since the ViewController has no window, it doesn't get standard life cycle events like you said, but didTransition(to presentationStyle: MSMessagesAppPresentationStyle) still gets called so that's where I've put this.

jecls
  • 31
  • 1
  • 2