Steps to recreate:
- File > New
- Change Width and Height to a large number
- File > Open > Open File
- Select a small image (eg a 50px by 50px icon)
- Canvas gets resized to the width and height of the image
It happens whether the inserted image is smaller or larger than the canvas. Of course, canvas being resized upwards isn't as big an issue as having the canvas shrunk to 50px by 50px.
However, when there is already something else on the canvas, inserting a new image will not resize the canvas.