Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resources not being deallocated causing renderer crash #2531

Open
Ottozz opened this issue May 8, 2024 · 1 comment
Open

Resources not being deallocated causing renderer crash #2531

Ottozz opened this issue May 8, 2024 · 1 comment
Labels

Comments

@Ottozz
Copy link

Ottozz commented May 8, 2024

Hello,
I'm using the GeoTIFFTileSource plugin to display several .tiff images in an electron app, building the tiles using Sharp.js and passing them to the viewer:

Main Process:

const buildtiledTif = async (filePath) => {
    try {
        return await sharp(filePath, {limitInputPixels:false}).tiff({tile:true, pyramid:true}).toBuffer();
    } catch (err) {
        await database.log('ERROR', err.stack);
    } 
}

Renderer Process:

const updateScanImage = async (filePath) => {
  /* close the viewer */
  viewer.close();

  /* Build tiled tiff */
  const typedArray = await window.electron.sharp("build-tiled-tif", filePath);
  const arrayBuffer = typedArray.buffer.slice(typedArray.byteOffset, typedArray.byteLength + typedArray.byteOffset);

  /* generate tiffTileSource and open viewer */
  const tiffTileSources = await OpenSeadragon.GeoTIFFTileSource.getAllTileSources(arrayBuffer);
  viewer.open(tiffTileSources);
}

After some issues with loading the images from a local arrayBuffer, I managed to pass the tiled image to OSD and open it with decent performances (~2s to open a ~200MB file).
The issue I'm now facing is that the resources (tiles) loaded are not deallocated even after closing/destroying the viewer and keeps on adding into memory at every pan/zoom/image replacement, eventually leading to renderer going out of memory:

clientWin.webContents.on("render-process-gone", (event, details) => {
        console.error("gone", details) // This prints: { reason: 'oom', exitCode: -536870904 }
    })

I originally opened the issue on the GeoTIFFTileSource repo (pearcetm/GeoTIFFTileSource#9), however I think it may not be strictly related to the library itself, so I'm opening one here as well.

@iangilman
Copy link
Member

I believe OSD is generally pretty good about releasing its resources, so my guess is this has something to do with it running in Electron, or the use of Sharp, or something. I think the next step is to try to narrow it down to isolate where the issue is coming from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants