fix crash on window size decrease