Maybe it can be for some use.
I've attached the minimal patch which fixed issue for me.
This patch reverted some of your changes.
Because when I move to full screen => toolbar is dissapear, I feel that the root cause is replacing layoutSublayersOfLayer to layout.
Anyway, I don't know quartz and I can't minimize it future.