Wordpress-ios: EXC_BREAKPOINT: initialDetailViewControllerForSplitView:

Created on 4 Jun 2019  路  6Comments  路  Source: wordpress-mobile/WordPress-iOS

Sentry Issue: https://sentry.io/share/issue/38dd20cbc7d4411784da5f7d61a613d9/

EXC_BREAKPOINT: initialDetailViewControllerForSplitView:
  File "UIImage+Assets.swift", line 20, in UIImage.gravatarPlaceholderImage.getter
  File "MyProfileViewController.swift", line 27, in makeHeaderView
  File "MyProfileViewController.swift", line 10, in MyProfileViewController
  File "MeViewController.swift", line 238, in MeViewController.myProfileViewController.getter
  File "<compiler-generated>", in MeViewController.initialDetailViewControllerForSplitView
...
(51 additional frame(s) were not displayed)
/Me [Pri] High [Type] Crash

All 6 comments

This seems to be happening a lot in 12.5.0.3

Adding a [Pri] High label because a new crash and because @JavonDavis noted it's happening a lot.

10-day impact: ~43 per day
Users affected: 31 in the last 10 days
First seen in: 12.5

(https://sentry.io/share/issue/38dd20cbc7d4411784da5f7d61a613d9/)

@designsimply As we discussed yesterday, the workaround for this was released in 2.5.1. It should no longer be happening for users. We are keeping the issue open as we would like to get to the root cause of this to ensure it doesn't happen again.

I believe I have found the cause of this and I'm working on a fix.

Cause

The version of WordPressUI that was shipped in 12.5 added a resource_bundles entry to its .podspec (see https://github.com/wordpress-mobile/WordPressUI-iOS/pull/31). This is a feature of CocoaPods that bundles together the files you specify into a .bundle to be included by the pod. In the case of WordPressUI, the resource bundle includes an asset catalog for loading images and a storyboard file. The change was made to allow the pod to work when integrated both statically and dynamically.

The problem is that when CocoaPods generates the Info.plist for a resource bundle, it uses the exact same format for the bundle identifier as for regular pod targets (i.e. org.cocoapods.${PRODUCT_NAME}). Since the Product Name of the resource bundle and the pod itself is the same (WordPressUI), both WordPress.UI.framework and WordPressUI.bundle end up with the same bundle identifier (.org.cocoapods.WordPressUI).

The line that crashes is this:

UIImage(named: "gravatar", in: bundle, compatibleWith: nil)!

Most of the time, this is fine, but it appears that iOS uses the product identifier of the bundle when loading images from an asset catalog (mentioned in this Radar). This means that even though we have passed in the correct bundle here, iOS internally uses something like Bundle(identifier: "org.cocoapods.WordPressUI") to load the bundle. Since this can match either the Framework or the Bundle, the image may not be found and the force unwrap can cause a crash.

Possible Fixes

We have a few options to solve this issue:

  1. Fix the issue in CocoaPods so that this conflict can't happen. I will open an issue there regardless.
  2. Rename the resource bundle in WordPressUI to something like WordPressUIResources. I tried this before and encountered some issues with storyboard loading but I will try again.
  3. Override the bundle identifier of the bundle using a pod_install hook. this would work but is quite hacky.

I have implemented solution 2 here: https://github.com/wordpress-mobile/WordPressUI-iOS/pull/37

I was able to update the module the storyboard issue to resolve the loading issue I mentioned.

Was this page helpful?
0 / 5 - 0 ratings