09564e167a
The window dimensions are integers, so resizing to fit the content may not be exact. When computing the optimal size, it could cause to reduce the width and height alternatively by few pixels, making the "optimal size" unstable. For the same reason, during rendering, the content size could be different from the optimal window size, leading to black borders (supposed to be removed in optimal size). To avoid this problem, always choose the same dimension if the choice to resize the width or the height is in the error range.