[r200] Load image from URL or NWjs bug V2

0 favourites
  • 3 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

    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?

    Added from old post

    [quote:1g8zpd8h]'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.

    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

    r200

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think this is because the Sprite object ignores loading the same image URL twice. If you load C:\image.png twice in a row, the second time it ignores it because it's the same path and is assumed to be the same image. This is important especially when loading images in to multiple objects, e.g. your other example with 5 sprites all loading the same image: it recognises they're all the same and only loads one texture. If it loaded it every time, it would load the image five times and use five times as much memory. So I think this "ignore the same URL" behavior needs to remain. However it means if you load C:\image.png, then copy over that file, then load it again, it still ignores it - it doesn't know it's changed. (This is the kind of thing that can happen locally but is rare on the web, images at URLs rarely change that easily.)

    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.

  • The problem is the image is chosen by the user of the application through NW.js file dialog and when copied the files are automatically renamed, due to a load and save functionality in my program, so the image(s) needs to be overwritten if the user choose another file and then update the file in my program. However it wont do that because of this problem, which makes NW.js somewhat incompatible when reading an image from the disk when used with the file/folder dialog.

    And my program already have so many workarounds for video not showing when loading, so to fix that, you have to play the video, then stop it, reverse it back to start and pause it. Not able to load audio files during runtime, so to fix that I had to make another workaround to use a video object instead, which makes little sense and also looses all features from the audio object. So I had to apply another fix to the audio functionality as well. The resize of image load had a workaround as well. (which is fix in the last release which is awesome, so thanks a lot for that, really neat.)

    The other bug report regarding the several folders uses a fix as well. I installed the NW.js 0.12.0 Alpha from here: https://www.scirra.com/forum/nw-js-formerly-node-webkit-news-and-update_t122727 pretty sure I already had that one, but if that's the one you are referring to as 0.12.0 in the other post, then the problem is still the same. I will reply to that one in the other post.

    But this is just some of the workarounds, can't remember them all. but they just seem to keep pilling up. So its workaround after workaround and it just keeps lowering the quality of the application im trying to make, because I constantly have to remove things, make weird solutions etc.

    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 then if you need one 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?

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