fix crash when switching to/from fullscreen when using CALayer mode.