Page MenuHomePhabricator

Location manager crash from Toby's phone
Closed, ResolvedPublic

Description

His feed was super sluggish and mostly showing just placeholders.

Video of Toby's phone:

His release was 5.0.4

	 git checkout "releases/5.0.4.851.1"

The "locationManager:didChangeAuthorizationStatus:" method in WMFLocationManager.m is called repeatedly with the following parameters:

        "manager" parameter:
	        is a different pointer each time
        "status" parameter:
	        is always kCLAuthorizationStatusAuthorizedWhenInUse

His location permissions for the Wikipedia app were set to "while using". Checked under "general > settings > privacy > location services".

Related?
http://stackoverflow.com/questions/30106341/swift-locationmanager-didchangeauthorizationstatus-always-called

Some console output:

The app data: (I was able to build and install 5.0.4 on my phone and run it, then under Devices I was able to replace the container with this one - it actually crashed my phone quickly, whereas on Toby's phone there was not crash, just the looping call to "locationManager:didChangeAuthorizationStatus:")

Potentially related buggy looking code:

  • Our "+ (BOOL)isAuthorized" method is checking for kCLAuthorizationStatusAuthorizedWhenInUse twice instead of once for kCLAuthorizationStatusAuthorizedWhenInUse and once for kCLAuthorizationStatusAuthorizedAlways.

Event Timeline

Mhurd renamed this task from Location manager crash from Toby to Location manager crash from Toby's phone.Jul 11 2016, 9:58 PM
Mhurd updated the task description. (Show Details)
Mhurd updated the task description. (Show Details)

@Fjalapeno @JoeWalsh @JMinor wasn't sure where to put this... seemed critical now that we have some data

Mhurd updated the task description. (Show Details)

We're frozen on 5.0.5, so this would need to be fixed in 5.1.

If this is obviated by feed provider changes, great, otherwise we should fix this specific issue with high priority.

When fixing this, it would be good to also fix https://phabricator.wikimedia.org/T139944 - location tracking is occurring necessarily, partly due to the behavior of the authorization checking methods @Mhurd pointed out

@Fjalapeno @Mhurd The issue is caused by sections missing from the NSCache sectionControllersBySection in WMFExploreSectionControllerCache. Switching this to an NSMutableDictionary resolves the issue. Since NSCache is somewhat unpredictable in what & how it evicts, it might be worth manually managing a dictionary.

[edit]or use the cache:willEvictObject: delegate method <-- this doesn't work, the sections/controllers being evicted from the cache are the newest ones

@Fjalapeno @Mhurd this is the smallest/quickest fix:
https://github.com/wikimedia/wikipedia-ios/pull/775

Is the feed pruned elsewhere? In the current code, NSCache is set to evict at a certain count limit but even after updating it to keep it in sync with the reverse lookup, the missing items were still trying to load forever.

Given the severity of the issue and the fact that it affects anyone with a feed over a certain length, I think the fix should be pulled into 5.0.5.

Updated the fix to include cache pruning responsibility for WMFExploreViewController.