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

File I/O Initialization: Redundant DLL Calls? #11

Open
tajmone opened this issue Feb 15, 2021 · 0 comments
Open

File I/O Initialization: Redundant DLL Calls? #11

tajmone opened this issue Feb 15, 2021 · 0 comments
Assignees
Labels
🔌 file I/O plugins Pro Motion file I/Oplugins ♻️ question Further information is requested

Comments

@tajmone
Copy link
Collaborator

tajmone commented Feb 15, 2021

FAKE Plugin v0.0.9 | PMNG 7.2.0.7

@jan-cosmigo, the Fake plug-in is a proof-of-concept File I/O plug-in which fakes exporting images to the .fake format (doesn't actually save anything) as an excuse to log all the DLL calls that PMNG executes to the plug-in, both at initialization time as well as when exporting.

NOTE — You'll always find the pre-compiled DLL of the latest version on our shared GDrive folder, which is automatically deployed when I build the final DLL.

This plug-in has helped me get a better insight about how the File I/O interface actually works in real case scenarios, and provided me with the order in which DLL functions are called.

But it also shows some strange things, i.e. that PMNG seems to call some initialization functions more than once. I'm not sure why this happens, and whether it's caused by the fact that the plug-in causes a slight delay in its responses due to the visual logging, or whether that's the way the interface is supposed to work.

In any case, I though it was worth providing you with the latest logs, in case these redundant calls are not supposed to occur, and also because I'm curious about them since I've noticed that their occurrence is not fixed and might change depending on how many plug-ins are present in the plugins/ folder.

Initialization Log

Here's the full log from when the DLL is attached to PMNG's process up to the end of all initialization calls:

13:48:43 | initialize(*language, *version, *animation)
         | | *language  <--  'en'
         | | *version    --> 1
         | | *animation  --> 0
13:48:43 | getFileBoxDescription()
         | | --> "FAKE - PureBASIC"
13:48:43 | getFileBoxDescription()
         | | --> "FAKE - PureBASIC"
13:48:43 | getFileBoxDescription()
         | | --> "FAKE - PureBASIC"
13:48:43 | getFileBoxDescription()
         | | --> "FAKE - PureBASIC"
13:48:43 | getFileBoxDescription()
         | | --> "FAKE - PureBASIC"
13:48:43 | getFileBoxDescription()
         | | --> "FAKE - PureBASIC"
13:48:43 | getFileBoxDescription()
         | | --> "FAKE - PureBASIC"
13:48:43 | isReadSupported()
         | | --> false
13:48:43 | isWriteSupported()
         | | --> true
13:48:43 | getFileBoxDescription()
         | | --> "FAKE - PureBASIC"
13:48:43 | getFileExtension()
         | | --> "fake"
13:48:43 | getFileBoxDescription()
         | | --> "FAKE - PureBASIC"
13:48:43 | getFileExtension()
         | | --> "fake"
13:48:43 | getFileExtension()
         | | --> "fake"
13:48:43 | getFileBoxDescription()
         | | --> "FAKE - PureBASIC"
13:48:43 | getFileExtension()
         | | --> "fake"
13:48:43 | getFileExtension()
         | | --> "fake"
13:48:43 | getFileExtension()
         | | --> "fake"
13:48:43 | isReadSupported()
         | | --> false
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:43 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:45 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:45 | isReadSupported()
         | | --> false
13:48:46 | getFileTypeId()
         | | --> "purebasic.fake"
13:48:46 | getFileTypeId()
         | | --> "purebasic.fake"

As you can see, getFileBoxDescription() is called multiple times (10 times!), and so is getFileTypeId() (29 times), as well as others (but not all).

I was wondering whether this has to do with the fact that PMNG has multiple File I/O interfaces (image import/export, animation import/export, palette import/export, and so on), which would explain why these are called multiple times — although it would make more sense to call them once and store the returned values, or memoize these calls to avoid redundancy (I've noticed that when there are more than 3 plugins PMNG startup can get quite slow).

Image Export Log

And here's the log from a simulated image export (Save Image As » "FAKE"):

13:55:04 | isReadSupported()
         | | --> false
13:55:04 | isReadSupported()
         | | --> false
13:55:10 | getFileTypeId()
         | | --> "purebasic.fake"
13:55:10 | getFileTypeId()
         | | --> "purebasic.fake"

... up to when I chose the "FAKE" format in the PMNG export dialog.
(again, you can see the duplicate calls)

And then, after having confirmed the "FAKE" format and the next PMNG's options pop-up dialog (pixel scale, effects, etc.):

13:56:06 | getFileExtension()
         | | --> "fake"
13:56:06 | getFileExtension()
         | | --> "fake"
13:56:06 | setFilename( $062037CC )
         | | *filename_pnt <-- "D:\test\KongTest.fake"
         | | FILE: KongTest.fake
13:56:06 | getFileTypeId()
         | | --> "purebasic.fake"
13:56:06 | setFilename( $062037CC )
         | | *filename_pnt <-- "D:\test\KongTest.fake"
         | | FILE: KongTest.fake
         | | (same as before)
13:56:06 | beginWrite()
13:56:06 | writeNextImage()
13:56:06 | finishProcessing()
13:56:06 | getFileTypeId()
         | | --> "purebasic.fake"

Of all these redundant calls, only the double call to setFilename() might actually affect plugin developers, depending on how the call is handled — as you can see from the second call in the above log, the FAKE plugin explicitly checks if the filename being passed is the same as the previous one, a check I introduced when noticing that the function might be called multiple times during a single image export operation.

The rest of the redundant calls are not really a concern to developers, since they are just plugin-info retrieval calls (which plugins should blindly obey to).

I was just curious on why all these redundant calls are there — especially since I'm planning to work an a File I/O simulator, to simplify testing plugins during development (i.e. not having to close and launch PMNG at every code edit, but just for final testing).

@tajmone tajmone added ♻️ question Further information is requested 🔌 file I/O plugins Pro Motion file I/Oplugins labels Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔌 file I/O plugins Pro Motion file I/Oplugins ♻️ question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants