Game lags in Steam

When I test play my game in Steam, the framerate drops to 4-5 frames per second at random times, usually after I've played some time. This does not happen when I test play the game outside of Steam. I used an achievement script in the game earlier, but removed it and the achs but the game still lags.
I don't know if this is the right address to ask about this, but I'd be grateful if someone had any idea what's going on.
Are you encrypting your images and audio? Have you tried playing the game with encrypted files but without steam to check if the same problem occurs?
I have only been using the Vx Ace built-in encryption where you have to check the boxes "encrypt game data" and "include RTP." I don't think it encrypts images or audio.

Original thread: https://forums.rpgmakerweb.com/threads/game-lags-in-steam.87200/