What causes white foam on the surface of a swimming pool?

I have found that the use of so-called waterproof sunblock lotions cause a white sludgy foamy texture on the surface of my pool. I was using 45 SPF No-Ad WaterProof Lotion and it came right off - even after applying 45 minutes before. I switched to Banana Boat 35 SPF waterproof and sweat-proof and the white stuff disappeared. That could be one solution. Good luck. And possibly overuse of a certain type of algaecide.