I encounter a WebGL error (It is undefined behaviour to use a uniform buffer that is too small) when toggling lights on a scene with freezed materials.
I tried to unfreeze materials before toggling a light and it doesn’t throw any errors.
When freezing a material, the current state is “frozen” and especially the lights that were in effect at freezing time. If later on you modify the set of lights that are in effect, it will crash (as you experienced it). The workaround is to do what you did: unfreeze the materials, modify the lights, freeze the materials again.
We would need to record the whole state at freezing time (maybe there are other things than the lights that may break) and compare the current state with the frozen state each time we have to draw something… Not very easy and efficient I think.