Fix the bug that platform surfaces are not freed