The problem you saw with the closed cell foam pulling away like that is due to the heat of the foam was to hot. It was actually curing out and making foam before it could adhere to the wood. The installer wasn't reading his foam correctly. He should of stopped and turned down the heat on his hose temp. Also installers have to be aware that as the sun rises and the temp in attics rises the subtrates get hotter as well. This will cause the installer to adjust his heat when installing the foam as the temp changes thru out the day.  
Today, each of the 50 states follows a different set of building codes making navigating these codes confusing, particularly for architects or builders that have projects in multiple states. In some cases, the building code changes significantly between the state and certain cities or counties within the state. For example, at the time of writing Arizona had adopted the 2015 IRC Building Code, however, Phoenix was on the 2012 IRC, IBC and IECC code. With the majority of states either on the 2009, 2012 or 2015 code, below are some high-level points to consider and about how spray foam insulation contributes.
When choosing a waterproofing and sealing product, we must see to it that we can easily use and apply it using simple tools, including a squeegee or a paint roller. With ease of application, we can be certain that we can achieve hassle-free application and smoother and more attractive finish than other products could give. So when reviewing the products we have featured above, we have made sure that they are easy to apply.

Roof Coating