Fix crash of window, add warning for log it too long