Imagereader error reporting & handling#3150
Conversation
Fail if either of these is not correct, this ensures a random data image will not be loaded
|
The initial issue was a little vague with what exactly it wanted from a fix. So I've just taken a look at what is currently possible without modifying VTK. Ideally, if the VTK source could be changed so that the But if you have any changes you'd like then I can take a look at those too. |
Definitly not what we want, because VTK errors should be locked behind --verbose anyway
I did not look at the code yet, but all other reader behave like change 1 and I think this is enough. |
mwestphal
left a comment
There was a problem hiding this comment.
answered some questions; feel free to request another review when needed
Sorry, by "prints errors" I meant it should emit the same VTKErrors (or maybe warnings?) when the CanReadFile function is called. vtkNew<vtkPNGReader> reader;
reader->SetFileName("abc.notpng");
reader->Update(); // Emits an error about invalid header
reader->CanReadFile("abc.notpng"); // TODO : Should also emit error about invalid headerThis has no current ramifications for F3D, but it would mean for a VTK programmer, if they do use code like if (!reader->CanReadFile(file) {
exit(0);
}Then a user can get valid debug information by turning on VTK error printing. Relevant code where you can see debug info printed, vs not printed. Back to this PR though, yes sure I can remove change 2 if you'd like. Would you like me to add the message telling users about using --verbose? or maybe just a message specifying which file failed? (sorry about the delay btw, subnautica 2 just came out haha) |
|
Unless I'm mistaken,
Thats not necessary
Im not against that but it would have to be generic for all formats, not just images. But I think this is a different issue witha a different fix. |
No worries, enjoy :) |
53a80e2 to
44dd75b
Compare
|
Need any help moving forward @iommu ? :) |
1 similar comment
|
Need any help moving forward @iommu ? :) |
|
Ah! Hi, so sorry, I got very sidetracked. Ah yes last I modified this I believe it should do what you requested it should :) If you have any specific changes beyond this I can take a look into it, but at the moment I believe this should do what you're intending it should. |
mwestphal
left a comment
There was a problem hiding this comment.
LGTM, please add a test though :)
Describe your changes
In normal f3d usage, Imagereader failing to read a file would result in silenced errors and produce a un-intialized buffer. E.g.
f3d --no-config --force-reader=PNG f3d.glbresults in :Note : this behaviour would change if --verbose was specified to the command line
f3d --no-config --force-reader=PNG f3d.glb --verboseand warnings would be visible in the CLI and GUI, however the corrupted image would still appear.I have implemented 2 main changes to improve this.
When
vtkF3DImageImporteris trying to import an image it will check if the reader calledUpdateInformation()correctly and also check if the error codes were set on readerreader->GetErrorCode() != 0.When the f3d::scene is trying to first add the image importer to the list of importers we check if
reader->canRead(...)returns successful.If unsuccessful & running with default verbosity an error is thrown* which specifies the user can use the
--verboseflag for more information.If unsuccessful & running with verbosity == debug then a warning is thrown but the code will continue on like it used to**.
* should we throw an error or simply print a debug line? It seems a lot of similar code in this file throws an error e.g. if f3d couldn't find a reader for the file type specified. But this implies that one bad file in a batch import can throw the entire scene correct?
** as canRead() generally does not provide any VTK errors as to why an image failed, a debug option (locked behind verbosity == debug) is provided which will continue on to run the code listed above and will print any VTK errors provided by the reader.
Before any changes
f3d --no-config --force-reader=PNG ./testing/data/f3d.glb # No errors printed, but random image displayedAfter change 1
f3d --no-config --force-reader=PNG ./testing/data/f3d.glb Some of these files could not be loaded: failed to load scene /home/iommu/Desktop/f3d/testing/data/f3d.glb # Error (as shown ^^^) is printed to terminal and to GUI "!" and no image is displayedAfter change 2
After change 2 : verbose
Issue ticket number and link if any
#2929
Checklist for finalizing the PR
.github/workflows/versions.json, I have updateddocker_timestampAI Disclosure
Continuous integration