How to get the in-scene-width of the canvas?

I’m not sure what you call “viewport” (is it the wall?).

Anyway, I think your problem is that you would need continous collision detection (CCD) if you don’t want to go through a wall whatever the speed of the object/camera. See for eg:

If you don’t want to use a physic engine for CCD, this may get you started: