It is currently 02 May 2025, 16:47
   
Text Size

Lazy CardFactory loading is the problem . . . or is it?

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Lazy CardFactory loading is the problem . . . or is it?

Postby Braids » 28 Jun 2011, 06:28

i've been trying to reproduce and track down the alleged bugs with the lazy CardFactory loading:
  • New quest mode hangs
  • Only colorless cards placed into 3-color generated decks
  • Unacceptable behavior in deck editor (vague)

i wrote some unit tests. i slapped a stderr progress meter into ReadCard so i would know when it was done loading cards.

the unit tests passed with flying colors.

i added a call to getCards within CardFactory's constructor, so that it behaves like it did before r10095. it loads all cards at time of construction. the bugs are still there mostly.
  • New quest mode still hangs badly
  • I noticed a two-colored card in my hand in my 3-color generated deck, but most of the cards were still colorless.
  • The deck editor takes a long time to load, even after all the cards have loaded into memory. It prefers the window to be resized before it updates its contents (i.e., after clicking on a card or scrolling).

i promised myself no more late night commits, so the changes i made are still private.



btw, Goblin Hero has given us strikethrough at my request. use the s button, between Font colour and spoiler= in the BBCode editor. it makes for more dramatic redactions and has immense humor potential. Goblin Hero is awesome.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: Lazy CardFactory loading is the problem . . . or is it?

Postby Chris H. » 28 Jun 2011, 12:08

Using rev 10131 starting a new quest also appears to hang my computer. It pegged the processor, I waited about 1 minute and I gave up and did a force quit.

I can apparently continue an existing quest. I can scroll through the quest mode deck editor and the card descriptions in the card detail panel look OK.

When I scroll through the constructed mode deck editor the card descriptions in the card detail panel look OK for some cards. Other cards have either no description or are unparsed.

The filters for the constructed mode deck editor have some problems. This may be related to the updating the card list in the table.

Playing a match by selecting Constructed -> Generate Deck - > 2-Color Deck (new) results in an null error exception:

An error has occurred | Open
An error has occurred. You can copy/paste this message or save it to a file.
Please report this, plus what you tried to do, to:
viewforum.php?f=26
If you don't want to register an account, you can mail it directly to
mtgerror@yahoo.com


n must be positive


Version:
Forge -- official beta: $Date: 2011-01-06 11:34:48 -0500 (Thu, 06 Jan 2011) $, SVN revision: $Revision: 4891 $

OS: Mac OS X Version: 10.6.8 Architecture: x86_64

Java Version: 1.6.0_24 Vendor: Apple Inc.

Detailed error trace:
java.lang.IllegalArgumentException: n must be positive
at java.util.Random.nextInt(Random.java:250)
at forge.deck.generate.Generate2ColorDeck.get2ColorDeck(Generate2ColorDeck.java:180)
at forge.Gui_NewGame.generate2ColorDeck(Gui_NewGame.java:953)
at forge.Gui_NewGame.genDecks(Gui_NewGame.java:833)
at forge.Gui_NewGame.startButton_actionPerformed(Gui_NewGame.java:743)
at forge.Gui_NewGame$13.actionPerformed(Gui_NewGame.java:552)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6374)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6139)
at java.awt.Container.processEvent(Container.java:2085)
at java.awt.Component.dispatchEventImpl(Component.java:4736)
at java.awt.Container.dispatchEventImpl(Container.java:2143)
at java.awt.Component.dispatchEvent(Component.java:4566)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4621)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
at java.awt.Container.dispatchEventImpl(Container.java:2129)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4566)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:680)
at java.awt.EventQueue.access$000(EventQueue.java:86)
at java.awt.EventQueue$1.run(EventQueue.java:639)
at java.awt.EventQueue$1.run(EventQueue.java:637)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:653)
at java.awt.EventQueue$2.run(EventQueue.java:651)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:650)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Lazy CardFactory loading is the problem . . . or is it?

Postby slapshot5 » 28 Jun 2011, 12:24

Chris H. wrote:Playing a match by selecting Constructed -> Generate Deck - > 2-Color Deck (new) results in an null error exception:
I did not get this error when I just tried it in r10003 (the last beta revision). Just FYI.

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: Lazy CardFactory loading is the problem . . . or is it?

Postby Braids » 28 Jun 2011, 15:34

i have backed out the changes to the LazyCardFactory and ReadCard.

they are still in the svn tree, but they have been reverse merged out as of r10141.

Edit 1: the rollback seems to have had the following positive effects:
  • Generating a 3-color deck now adds mostly colored cards.
  • Starting a new quest no longer freezes.
  • The deck editor seems faster and more responsive.

i am frustrated. the changes to CardFactory and ReadCard were supposed to be transparent. but they introduced subtle systemic bugs that i do not comprehend.

Edit 2: please keep in mind that i even forced the CardFactory to load all the cards in its constructor, so the behavior was allegedly the same as before the changes. that did not even help.

the quotes below are from another thread at http://www.slightlymagic.net/forum/viewtopic.php?f=26&t=4884&p=63547#p63547

Rob Cashwalker wrote:Braids, don't give up on it....
don't give up what exactly? the lazy CardFactory? i don't have the patience right now to diagnose the strange systemic behaviors above. i won't give up on speeding up my unit tests though.
Rob Cashwalker wrote:After startup the only major delay is loading the main deck editor . . .
you are right. the program seems to run more smoothly with the old CardFactory.
Rob Cashwalker wrote:There are ways to reduce the load time without necessarily having a lazy CardFactory. If you use the cardsfolder.zip option, then it should be a bit faster . . .
my main reason for doing this was to eliminate the long startup time for unit tests. thanks for the tip. i will see if that helps.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 17 guests


Who is online

In total there are 17 users online :: 0 registered, 0 hidden and 17 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 17 guests

Login Form