How can I prevent frame spikes when activating parts of a level?

My project has large linear scenes the player travels through. For performance, we group the scenes in to chunks and keep them “inactive” and set them active when the player gets close to them. My problem is that calling the call to SetActive can cause a large (> 33ms) frame spike. Is there a better way to go about this?

It would be fine if the time spent was at before the level starts, but it seems to have no effect to leave every section active for a few seconds before hiding it.

It may be caused by loading new objects or shaders for the first time. An easy solution is to leave all your chunks active in the scene and set them inactive after game starts.
Another way around is to read about Unity methods like Shader.WarmupAllShaders() and similar and to try them out.

I don’t know if this works for you as it would probably require lots of rework in your scene-structure but I think many people split their bigger levels up into multiple scene and use LoadSceneAsync for stuff like this:
https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadSceneAsync.html

If you’ve played “Inside” I think that’s what they used there for example.
Hope this helps!