-
Notifications
You must be signed in to change notification settings - Fork 5
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
Input a TIFF from local buffer without uploading file #9
Comments
I'm not surprised doing it this way in Electron takes a long time - you basically are having to load the entire giant file into memory before doing anything else. The beauty of GeoTIFF.js is that it only requests and reads specific locations within the file; the GeoTIFFTileSource makes use of that to request specifically the image data needed for the current view. So, a whole lot less data is read at once. A couple of thoughts:
I guess in the short term, I'd recommend having users pick files to view using an |
Hello @pearcetm, thanks for the reply! I had better luck loading the File objects in a keyval IndexedDB , using it as a sort of cache, allowing to open them almost instantly. But I ended up dropping this approach as it is not really a good solution when having many (50+) large files (~ 80-200 MB) . In the end I was able to overcome the performance issue (i.e. slowness) by modifying the library and changing the geoTiff method invoked if the input is not an instance of a File from Main Process: return await sharp(sharpInput, {limitInputPixels:false}).tiff({tile:true, pyramid:true}).toBuffer(); 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);
} However I now face Electron's white screen of death (renderer crash) after opening different files (5/6/7...it vary a bit), even if I'm closing the viewer every time a new image is selected. I investigated on possible memory leaks and resource usage of the app (I used this as base for the debug) but didn't find anything relevant. I guess I should just give up an investigate further on your proposed solution # 3. |
As a follow up, I kept investigating the issue and believe that the crash is caused by the resources not beign deallocated when the imageTileSource is replaced (after Not totally sure if it is something strictly related to this library or to OpenSeaDragon itself, but maybe it's worth investigating a bit further. |
Interesting. I also am not sure whether this is due to something here in this library, or in OpenSeadragon (I see you've opened an issue over there: openseadragon/openseadragon#2531), or with application-specific code which is holding onto a reference somehow. One thing you might try is pointing the viewer at some TIFFs at remote URLs, like in the demo page. Does memory keep growing when you load images that way? In fact, does the demo page show memory growth if you keep loading and viewing files? That might help narrow things down. |
@Ottozz I've faced this spike as well, and I found the geotiff @pearcetm this is also addressed in the PR by making the geotiff pool a static property of the class, instead of being an instance property. Instead of de-allocating and recreating the Pool, I just reuse the existing set. |
Thanks for helping identify the problem here. Re-using the existing |
Hello, first of all thanks for the great tool!
I'm having success using it as shown in the demo, by uploading a file in an
<input type='file'>
tag which basically generates an instance of a File object. The Tiff opens up instantly even if it is quite heavy (~220MB).My use case now is to read the same files from a local folder (in an electron app), without uploading the files, but reading them through Node's
fs
or through Sharp's.toBuffer()
method.I'm struggling to make it work with decent performance, since the library only accepts an instance of File object or an Url.
After several tries and conversions (buffers, arrayBuffers, Files, blob,..) I was able to (quite) get it working by doing something like this:
In Main Process:
in Renderer Process:
The same applies by replacing Sharp call with something like:
As you can see, the performances are not as great as uploading the same file in the
<input type='file'>
tag. (almost instant vs ~7seconds).Am I overcompicating things here? Is there a better way to do it?
The text was updated successfully, but these errors were encountered: