[r202] Load image from URL or NWjs bug V3 (Reopened)

0 favourites
  • 4 posts
From the Asset Store
Elevate your games with our AI Chatbot Integration! Seamlessly connect your Construct 3 projects with GPT-4 for dynamic,
  • Problem Description

    [quote:q63961jp]This might be a bit difficult to explain, because it makes little sense. But it appears that when you use NWjs to open an image and load it into a sprite using "load image from url", but at the same time copy the file to a new destination and tell it to use that one instead. And then load a new image it still uses the old image despite it doesn't exist anymore. Guess it might read it from memory maybe?

    ************************* NEW *****************************

    Sorry that I reopen this again and that it gets a bit messy, but its a bit confusing when these bug reports are just closed, without even being tested.

    You wrote that this could be a workaround:

    [quote:q63961jp]There is a workaround though: load a different image in between. If you load "image.png", then load "dummyimage.png", then load "image.png", it will really load it again since the URL has changed every time.

    However I should have tested it to see if it worked. But now I ran into the problem once more and since the original bug report was closed and no answer to my question in it, I kind assumed that it wouldn't/will be fixed.

    So I tried the workaround that you suggested and it doesn't work. The image is stuck in memory or whereever it is stored until the application is restarted.

    This is crucial for my program that this is possible and im starting to run out of idea of creating workarounds for this, except having to redesign my program yet again based on all these weird limitations.

    So please reconsider my suggestion in the original post:

    [quote:q63961jp]Wouldn't it be possible to simply duplicate the "Load image from URL" and make one called "Load image from disk" which forces update and if you need to use it for web you use the first one and if its from the disk where internet speed is not an issues you can use the other one?

    Or some other way, don't really care how its done, Maybe as someone suggested in the "General" section, something that will force it to clear memory or something. I can see the idea of not having to load images all the time. But what is point of keeping stuff in memory that doesn't even exist anymore.

    *************************************************************

    Added from old post

    [quote:q63961jp]'Load image from URL' is asynchronous: the action only starts it working, and it completes later when 'On image URL loaded' triggers. During the loading you synchronously copy and overwrite the file that is currently being loaded. This effectively makes it random which image you load, depending on which the system manages to do first: read the file, or copy the file over it. Further reading and writing to C:\ normally requires admin permissions on most systems, which C2 games don't run with by default.

    If you still think there is a problem, please file a new bug report that has a clearly ordered sequence of operations, and doesn't attempt to read or write files to/from system locations that normally require admin permissions to access.

    [quote:q63961jp]UPDATE:

    I have moved the files to my users folder and the files are copied only in this directory. And the problem is the same. I think you might have misunderstood the problem as its a bit weird to explain. But you write that it "depends on which the system manages to do first".

    But its not relevant in this case, because the two things are not happening at the same time.

    Meaning, between the copy and actually using the URL from where it was copied to, I can wait 5-10 seconds or whatever before I even tell it to use that path, and it will still load the old image even though that image have been deleted from the hard disk. Also the files are 1.85kb in size, so it should be more or less instant regardless.

    The problem happened when you do it exactly the way I descripted in the old post, but ill try to explain it again.

    Attach a Capx

    https://dl.dropboxusercontent.com/u/109921357/Load%20image%20from%20file%20bug.capx

    Description of Capx

    Allows you to select a jpg file and load it into a sprite. At the same time copying the file to "C:\Users\<Name>\Test\Test.jpg" Right clicking the image will load the image from C:\Users\<Name>\Test\Test.jpg.

    Steps to Reproduce Bug

    1. Double click one of the images and select a jpg file. The two images now uses the image selected through the chosenpath. At the same time a copy of the file is copied to "C:\Users\<Name>\Test\Test.jpg".

    2. Right click one of the images to use the URL "C:\Users\<Name>\Test\Test.jpg".

    3. Double click one of the images and select another jpg files than in step 1. The images now changes to this file as expected.

    4. Right click one of the images again to use the URL "C:\Users\<Name>\Test\Test.jpg" However instead of using the image from step 3, it uses the image from step 1, even though it is not at that URL anymore, and the image from step 3 is in that location it doesn't load it.

    Expected Result

    That it would read the file from the path its told and not from maybe memory.

    Affected Browsers

    Don't know.

    Operating System and Service Pack

    Windows 7

    Construct 2 Version ID

    r202

  • I decided to make a small test, hopefully it will illustrate the problem in full.

    Very simple program you press one button and choose an image to load. Press the other button, it load a "dummy" image and then the file where it was copied. (The suggested workaround) The wait was just to give it some time in case it had to update. But it makes no difference.

    Start:

    This is what the program looks like when its started and haven't done anything. The Nw.exe is from windows system.

    Test 1:

    I loaded a small image 64x64 and there are minor changes to NW.exe.

    Test 2:

    So I loaded in a 5000x5000 image and logically the NW.exe goes up.

    Test 3:

    So I press the second button, to load the "dummy" image which is also a 64x64 image (1kb) and use the copied file as my load from url. Now the NW.exe had pretty much doubled.

    Test 4:

    So I load a new one (64x64) however NW.exe are still using the same amount. And if I was to press the second button, it would switch back to the 5000x5000 image. Which could explain it.

    Depending on which order and what images I load. NW.exe will be either 126mb or 226mb. Even though you select another image as it goes back to use the old one. Its all a bit weird to be honest. Something with how the images are stored seems wrong.

  • Please do not post more than one issue per bug report thread. I am not sure if you want me to investigate the image loading issue or the memory issue. If your sole cause for concern with memory is what Task Manager says, that is a very complicated number: there are many layers of caching and duplication going on, so it basically can't be trusted. I believe C2's ImageMemoryUsage count is accurate, and looking at your screenshots it appears to end up at the correct low amount (3.17).

    The original report still has a few issues:

    • you are not sharing the images you are testing with (i.e. the Test.jpg file). You need to share everything your bug report uses to ensure I can reproduce exactly what you are doing.
    • you are still submitting reports based on accessing files in C:\, which is normally an admin-restricted folder. To rule out admin permissions as the cause of any problem, only access files in the application folder or user folder. (A global variable with the root path would be a good idea, so it can easily be changed if need be.)

    I'm going to close this report again, please file new issues (one issue per thread) respecting the above if you want this investigated further.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This is not to reopen it, but just to let you know if someone else report something similar.

    The problem is that C2 doesn't "allow" using the same filenames. So to make "Load from url" work as if it was updating the image, you have to save all files with new filenames each time. Which can be done by using the UID of the object with an index variable.

    So: [UID][Index],jpg

    00.jpg

    01.jpg

    Next time you have to overwrite the current loaded image, you delete the 00.jpg and save a new one as 01.jpg

    The only problem of course is that it will drain you computer for memory eventually.

    But anyway that will work around it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)