GeoServer freezes when switching WMS layers quickly — resumes after clicking the window

Hello GeoServer team,

I’m encountering a strange issue while using GeoServer to serve WMS layers in a Cesium-based frontend.

Here’s the situation:
• I’m running GeoServer on Windows using the standard “startup.bat” script.
• In my Cesium app, I load WMS layers using WebMapServiceImageryProvider depending on the imagery selected by the user. When users switch layers quickly, it can lead to a situation where one layer is removed and a new one is added almost instantly.
• When user do this quickly (e.g., switching layers within 1–2 seconds), GeoServer sometimes appears to freeze — tile requests stop processing and nothing loads further.
• However, when I right-click or interact with the GeoServer console window, it suddenly resumes responding and tiles begin loading again.

Here is a snippet of the code I’m using in JavaScript:

// Load Layer
const imageryProvider = new Cesium.WebMapServiceImageryProvider({
    url: SystemConfig.GeoserverWorkBase,
    layers: 'GeoWorkSpace:' + id,
    parameters: {
        service: 'WMS',
        format: 'image/png',
        transparent: true,
        tiled: true,
        srs: 'EPSG:4326',
    },
});
const imageryLayer = viewer.imageryLayers.addImageryProvider(imageryProvider);
imageryLayer._layerId = id;
// Remove Layer
const layers = viewer.imageryLayers;
for (let i = 0; i < layers.length; i++) {
    const layer = layers.get(i);
    if (layer._layerId === id) {
        layers.remove(layer);
        return;
    }
}

My Questions:

  1. What could cause GeoServer to pause or freeze in this way? Could it be related to AWT/Swing or thread blocking when running in GUI mode?
  2. Is it recommended to run GeoServer in background mode to avoid this issue?
  3. Are there any best practices to avoid this situation when rapidly switching layers using WMS?

Any insights or suggestions would be greatly appreciated.
Thank you for your time!

Best regards.