Wednesday, May 20, 2015

FormItem Column Count Issue

I ran into a problem today when loading a Form component with a couple of FormItem children.  The error message said, "The Form must have form items with the same number of constraint columns". In an effort to hopefully save somebody time in the future, here is the reason this showed up.  

One of my FormItem children had a skinclass defined on it, and the other didn't. The default skinclass provides three content columns (main content, sequence content and help content), while the other FormItem's custom skinclass only had two. When attempting to find the max width for each form item in a form it keeps track to make sure that all the FormItems have the same number of "content columns". If not the error will be thrown.

So to fix it I just had to make sure that every FormItem in the Form was using the same skinClass.

Friday, May 15, 2015

The Mystery of iCloud Photo Library Optimization

To say I was thrilled with the introduction of the iCloud Photo Library is an understatement.    I have been waiting for this type of single source library for years.  Of course I immediately turned it on for all  my devices and went all in (not completely in Photos for OS X, because my library was all referenced and it is a slow process moving them over).  I was also excited about the cool Optimize Storage option in iOS because in 2012, when I bought my iPhone 5, 16GB seemed like plenty of space.  

However, as I soon found out the Optimize Storage option would cause me more stress than I anticipated.  You see Apple decided that the optimization would be completely automatic with no opportunity for manual intervention for the user.  There is clearly some sort of algorithm that determines what full size versions of photos to keep on the device.  So far one of the rules revolves around photos taken within the last 30 days and there is also one based on photos that were downloaded locally to the device in the recent past.  It seems that no matter how low the available storage level goes the full size of these photos will remain on the device.  

I learned this because the other day I tried to take a video of my son playing baseball and got the dreaded "Video couldn't be saved because of insufficient space" message. My heart sunk because I thought barring some insane offline photo taking spree this error would never appear on my devices again.  My expectation was that in the worst case scenario if space was running low (as in I didn't have enough space to take one picture) that the "Optimize" setting would delete ANY photos that had already been uploaded to the cloud.  I figured maybe there were tiers:
if (availableStorage > 500MB) then don't do any optimization
if (available Storage < 500MB && availableStorage > 250 MB) then get rid of any full size copies of photos from more than 30 days ago that have been uploaded to the cloud
if (availableStorage < 250MB) then delete any full size photos that have been uploaded to the cloud

No such luck though, it seems to insist on keeping some amount of full size photos on the device even if they exist in the cloud.  I was bit by this recently because about 2 weeks ago I went on a trip and recorded a bunch of video, which went up to the cloud nearly the same day.  However, now the 1GB of videos from last month sits on my device and I have no way of deleting it without also deleting the copy in the cloud too.

I tried all sorts of trickery like trying to delete the photos using the Image Capture app on my MacBook.  I turns out the delete functionality isn't available if iCloud Photo Library is turned on for the device.  So I tried turning off the iCloud Photo Library on the phone and while the delete button appeared in Image Capture it didn't really do anything.

In the end I found the best way to get me back some space was to turn off the iCloud Photo Library on my iPhone, which freed up some space because it removed all the iCloud Photo Library thumbnail photos, but all the full size photos were still on the device.  At this point I was able to use the Photos app on my iPhone to remove photos and videos from my device, but not from the iCloud Photo Library. I also had to delete them from the "Recently Deleted" album too. Once I got rid of some of the videos that had been taking up so much space I turned the iCloud Photo Library back on and it started downloading the thumbnails again, but I now have a 1.5 more GB of free space on my iPhone.