Fixes a crash due to maskLayer not being retained