[1.3b56] BUG: tableImage() load failures

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice, MapTool BugReport Manager

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

[1.3b56] BUG: tableImage() load failures

Post by lmarkus001 »

When the function tableImage() is run, it does not always have a connected client fetch the image, so instead when the image is displayed it fails and you get the dreaded ?. If you repeat a fetch, the image will usually load on the second try. This failure to load causes a critical lockup failure if you try to use the image as a background image in a Dialog().

Test case:

Create a table called TestImageTable.
Put an image in row 1 of that table.
Start up the server.
Connect from a different MapTools client.
Run a macro that fetches the image and tries to display it (sample provided).

Failure condition: A ? will show in the input box instead of the desired image.

ImageFromTable

Code: Select all

[H: bgImage = tableImage( "TestImageTable", 1)]

[ok = input(
   "variableName| " + bgImage + "|Press OK if you can see the image (it is not a ?) |LABEL|ICON=TRUE"
)]


User avatar
codonell
Kobold
Posts: 12
Joined: Sat Jul 25, 2009 2:59 pm

Re: [1.3b56] BUG: tableImage() load failures

Post by codonell »

I can't reproduce this with a build from svn head.

After a fraction of a second I see the image load in the input dialog.

I'm testing with a client and server on a local network.

Under what network conditions are you testing this?

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: [1.3b56] BUG: tableImage() load failures

Post by Azhrei »

codonell wrote:I can't reproduce this with a build from svn head.

After a fraction of a second I see the image load in the input dialog.

I'm testing with a client and server on a local network.

Under what network conditions are you testing this?
Are you running both instances of MapTool on the same machine? That won't work since both are using the same folder for the assetcache, unless you've chosen different user IDs for each instance.

Oh, and welcome to RPTools!

User avatar
codonell
Kobold
Posts: 12
Joined: Sat Jul 25, 2009 2:59 pm

Re: [1.3b56] BUG: tableImage() load failures

Post by codonell »

I am running both instances on the same machine and connecting over loopback.

Do you have any details for launching two instances with different asset caches or user IDs?

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: [1.3b56] BUG: tableImage() load failures

Post by Azhrei »

codonell wrote:Do you have any details for launching two instances with different asset caches or user IDs?
Details? You mean other than choosing the Run As... option when executing the program? (The name of that option may have changed. I'm not a Windows user so I don't keep track of the phrase de'jour.) On my Mac or Linux box, I'd run the start script using sudo -u otheruser but that won't help a Windows user.

The MapTool assetcache is stored under the user's home directory in .maptool/assetcache, so a different user name would give a different home directory and thus a different assetcache.

User avatar
codonell
Kobold
Posts: 12
Joined: Sat Jul 25, 2009 2:59 pm

Re: [1.3b56] BUG: tableImage() load failures

Post by codonell »

I don't know how to easily launch two debug configurations from eclipse, and have one of them use a different Windows user ID.

Instead I augmented AppUtil.java to use a system property MAPTOOL_DEV_DATADIR to allow overriding of ".maptool" as the default maptool data directory.

I still can't reproduce this bug. I also verified that both instances of maptool are using different assetcaches.

Steps to reproduce:
* Launch first maptool from an eclipse debug launch
* Launch second maptool from an eclipse debug launch with -DMAPTOOL_DEV_DATADIR=".maptool2" as an additional argument.
* In the first maptool start a server.
* In the second maptool connect to the server 127.0.0.1 default port.
* In the second maptool create a button with the submitters macro.
* Click the macro button.

Observed behaviour:
* Dialog pops up, and for a fraction of a second I see a "?", after which the image loads correctly.

I made some additional changes to AppUtil.java including:
* Converting several hard coded "/" strings to File.seperator
* Added javadocs for the whole file.
* Refactored getAppHome.

Is there a developer mailing list for patches?

Changes to AppUtil.java attached as a patch.
Attachments
patch-2009-07-26-AppUtil_java_diff.txt
Diff of AppUtil.java
(4.91 KiB) Downloaded 114 times

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: [1.3b56] BUG: tableImage() load failures

Post by Azhrei »

Don't go too far with patches without consulting with Trevor (user id is the same) as patches need to fit cleanly into the framework he's developing. Somethings might be accepted and others might not. And he's the guy to send patches to.

Of course, you're always welcome to keep your source code in parallel to the main development tree.

User avatar
codonell
Kobold
Posts: 12
Joined: Sat Jul 25, 2009 2:59 pm

Re: [1.3b56] BUG: tableImage() load failures

Post by codonell »

lmarkus001,

What network configuration are you using to reproduce this bug?

Can you reproduce this with a client and server on different computers on a LAN?

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

Re: [1.3b56] BUG: tableImage() load failures

Post by lmarkus001 »

Host = Windows XP
Clients = mixture of Mac, XP, Vista

Clients have local network and external network connections (some are in my basement on my network, others are connected across the internet through my router).

MapTools 1.3b56

Without exception the clients will fail to load the image from the table on the first attempt. I have seen this on 8 different machines.

EDIT: The example I give is the most basic simple example. My failure is much more catastrophic in game as I use the tableimage() function to fetch the background image for a Dialog(), but if that image fails to load, the Dialog() freezes and you have to kill the MapTools process.

User avatar
codonell
Kobold
Posts: 12
Joined: Sat Jul 25, 2009 2:59 pm

Re: [1.3b56] BUG: tableImage() load failures

Post by codonell »

I can reproduce this now.

The issue only reproduces when the image on the server has never been seen by the client.

Previously in testing I was using one of the images from the Default library, but since both client and server (although using different asset caches) have the same image, it loaded correctly.

I'm looking into this.

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

Re: [1.3b56] BUG: tableImage() load failures

Post by lmarkus001 »

codonell wrote: The issue only reproduces when the image on the server has never been seen by the client.
...

I'm looking into this.
Exactly right! And thanks!

My current workaround is to loop through an input() pop up that asks the player to Cancel if they see the dreaded red ?. Once the ? goes away the image has been cached locally so now it can be used as a background image in a Dialog(). Ugly but it works :-)

User avatar
codonell
Kobold
Posts: 12
Joined: Sat Jul 25, 2009 2:59 pm

Re: [1.3b56] BUG: tableImage() load failures

Post by codonell »

Fundamentally the problem is this:
* AssetManager has a list of listeners waiting for object downloads to complete.
* ImageManager has a list of observers waiting for images to load.
* The AssetManager and ImageManager don't coordinate, and the ImageManager doesn't know when to load an image that hasn't yet downloaded.

The asset manager requests that a thread load the asset from the server, and therefore the asset is unavailable to the icon drawing code, so it instead draws the "?".

The second time around, the AssetManager's thread has had enough time to download the asset and it is taken from the asset cache and drawn correctly. In theory you will see "?" until the thread completes the download and adds the asset to the cache.

The workaround is definitely not a simple bug fix but a reworking of how the asset manager handles assets which are currently being downloaded.

The icon code needs to render the asset into a 2D image, and this has to happen all over again once the asset has finished downloading, but it doesn't.

I've fixed this by having the ImageManager coordinate with the AssetManager.

The following patch fixes the issue.
Attachments
patch-2009-07-28-tableImage_load_failure.diff.txt
(5.91 KiB) Downloaded 121 times

User avatar
codonell
Kobold
Posts: 12
Joined: Sat Jul 25, 2009 2:59 pm

Re: [1.3b56] BUG: tableImage() load failures

Post by codonell »

I've submitted this patch to Trevor for review.

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

Re: [1.3b56] BUG: tableImage() load failures

Post by lmarkus001 »

Awesome!

User avatar
trevor
Codeum Arcanum (RPTools Founder)
Posts: 11311
Joined: Mon Jan 09, 2006 4:16 pm
Location: Austin, Tx
Contact:

Re: [1.3b56] BUG: tableImage() load failures

Post by trevor »

On a side note, when you see a ? that means the file is in transit. if you see a X then the image is broken.

That should help identify which case you are running into (generally speaking). So in this case you can tell it's that the code that displays the image isn't getting informed when the image has finished downloading.
Dreaming of a 1.3 release

Post Reply

Return to “Resolved”