This question is answered.


Permlink Replies: 31 - Pages: 3 [ Previous | 1 2 3 | Next ] - Last Post: 20-Apr-2020 23:23 Last Post By: davidekholm Threads: [ Previous | Next ]
MarkusD

Posts: 515
Registered: 13-Apr-2006
Re: jA 20 freezes in Detail view
Posted: 17-Apr-2020 18:07   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
I'm just testing on my old computer (with 100% identical data copied with ROBOCOPY) what happens when I delete Titles, Comments and Keywords.
davidekholm

Posts: 3,192
Registered: 18-Oct-2002
Re: jA 20 freezes in Detail view
Posted: 17-Apr-2020 19:44   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Markus, please install the JDK (Java Development Kit), then issue "jps" from a command line. That will reveal jAlbum's process ID. You can naturally also get it via the task manager. Now issue:
jstack pid >threaddump.txt
where "pid" is the process ID of jAlbum. This will generate a log of what jAlbum is up to when it hangs. (Only run jstack when jAlbum is hanging)
MarkusD

Posts: 515
Registered: 13-Apr-2006
Re: jA 20 freezes in Detail view
Posted: 17-Apr-2020 20:02   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
Markus, please install the JDK (Java Development Kit), then issue "jps" from a command line. That will reveal jAlbum's process ID. You can naturally also get it via the task manager. Now issue:
jstack pid >threaddump.txt
where "pid" is the process ID of jAlbum. This will generate a log of what jAlbum is up to when it hangs. (Only run jstack when jAlbum is hanging)
OK, will try to do that.

What I've done meanwhile:

1) Delete all files "*.info", "meta.properties" and "comments.properties" to get ride of Title, Comment and Keyword of all objects;

2) Open JA and browse through all folders in the new Detail mode;

3) No freezing;

4) I pasted the well know text "Lorem ipsum..." a hundred times in the comment field of some folders;

5) Browsing in Detail mode through these folders is no problem;

6) So, I think it is not the amount of text in a comment field which makes trouble;

7) Then I included Titles and some Keywords, still not freezing;

8) I'll try to compile test album with only very small pictures (batch size resized to as small as possible) and no videos, but everything else (Titles, Comments and Keyword) still included. Hoping that this will show the freezing;
MarkusD

Posts: 515
Registered: 13-Apr-2006
Re: jA 20 freezes in Detail view
Posted: 17-Apr-2020 20:43   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Attachment threaddump.txt (30.5 KB)
Attachment 2020-04-17_204107.png (157.5 KB)
davidekholm wrote:
Markus, please install the JDK (Java Development Kit), then issue "jps" from a command line. That will reveal jAlbum's process ID. You can naturally also get it via the task manager. Now issue:
jstack pid >threaddump.txt
where "pid" is the process ID of jAlbum. This will generate a log of what jAlbum is up to when it hangs. (Only run jstack when jAlbum is hanging)
Hi David. See attached files.
karlmistelberger

Posts: 214
Registered: 5-Dec-2013
Re: jA 20 freezes in Detail view
Posted: 17-Apr-2020 21:22   in response to: MarkusD in response to: MarkusD
 
  Click to reply to this thread Reply
MarkusD wrote:
davidekholm wrote:
Markus, do you have a zip of an album project that reproduces this problem?

What I found out today:
1) On one computer (Windows 10 Pro, German. JA 20, Skin Tiger) I installed jAlbum very fresh and started it directly;
2) Then I started an album with Tiger and looked at all possible folders in detail view. Everything ran without problems;
3) Then I closed jAlbum and restarted it immediately;
4) After only a few clicks jAlbum froze;

On my workstation (Windows 10 Pro. German, JA 20, Skin Tiger) I viewed several albums with jAlbum in detail view. It took only a few seconds to freeze jAlbum. It was astonishing that after I killed jAlbum with the Task Manager, I was able to look at the parts in the detail-view without any problems, where the crash happened before.

I'm aware that this won't help you much because you can't reproduce the problem. But hope dies last.


Downloaded and unzipped jalbum-settings.jap and Prolog Viewed folder Prolog and switched between view modes. No delays, no freezing no problems of any kind encountered with openSUSE Tumbleweed, German, JA 20, Skin Tiger. ;-)
MarkusD

Posts: 515
Registered: 13-Apr-2006
Re: jA 20 freezes in Detail view
Posted: 17-Apr-2020 22:00   in response to: karlmistelberger in response to: karlmistelberger
 
  Click to reply to this thread Reply
karlmistelberger wrote:
Downloaded and unzipped jalbum-settings.jap and Prolog Viewed folder Prolog and switched between view modes. No delays, no freezing no problems of any kind encountered with openSUSE Tumbleweed, German, JA 20, Skin Tiger. ;-)
Thanks Karl for testing. It seems that maybe only one "strange" (long) comment is not a problem.

I compiled a test album and send a private message to David. Hopefully he can reproduce the problem. Thanks.
davidekholm

Posts: 3,192
Registered: 18-Oct-2002
Re: jA 20 freezes in Detail view
Posted: 18-Apr-2020 21:35   in response to: MarkusD in response to: MarkusD
 
  Click to reply to this thread Reply
Thanks for that thread dump Markus! I think I can solve it. The main UI thread is the "AWT" thread, it's blocked in a deadlock:
"AWT-EventQueue-0" #20 prio=6 os_prio=0 cpu=2984.38ms elapsed=112.64s tid=0x000001c5e48b0800 nid=0x14f4 in Object.wait()  [0x00000031d54fe000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(java.base@13.0.1/Native Method)
	- waiting on <no object reference available>
	at java.lang.Object.wait(java.base@13.0.1/Unknown Source)
	at javax.swing.text.AbstractDocument.readLock(java.desktop@13.0.1/Unknown Source)
	- locked <0x0000000708fbb0a8> (a javax.swing.text.PlainDocument)
	at javax.swing.plaf.basic.BasicTextUI.damageRange(java.desktop@13.0.1/Unknown Source)
	at javax.swing.plaf.basic.BasicTextUI.damageRange(java.desktop@13.0.1/Unknown Source)
	at javax.swing.text.DefaultHighlighter$SafeDamager.run(java.desktop@13.0.1/Unknown Source)
	- locked <0x0000000708fbb8d0> (a javax.swing.text.DefaultHighlighter$SafeDamager)
	at java.awt.event.InvocationEvent.dispatch(java.desktop@13.0.1/Unknown Source)

Now look at this thread (loading metadata):
"Metadata loader-thread-2" #73 prio=5 os_prio=0 cpu=1671.88ms elapsed=91.98s tid=0x000001c5e5380000 nid=0x2680 waiting for monitor entry  [0x00000031d60fe000]
   java.lang.Thread.State: BLOCKED (on object monitor)
	at javax.swing.text.DefaultHighlighter$SafeDamager.damageRange(java.desktop@13.0.1/Unknown Source)
	- waiting to lock <0x0000000708fbb8d0> (a javax.swing.text.DefaultHighlighter$SafeDamager)
	at javax.swing.text.DefaultHighlighter.safeDamageRange(java.desktop@13.0.1/Unknown Source)
	at javax.swing.text.DefaultHighlighter.safeDamageRange(java.desktop@13.0.1/Unknown Source)
	at javax.swing.text.DefaultHighlighter.addHighlight(java.desktop@13.0.1/Unknown Source)
	at com.inet.jortho.AutoSpellChecker.checkElement(AutoSpellChecker.java:196)
	at com.inet.jortho.AutoSpellChecker.checkElements(AutoSpellChecker.java:150)
	at com.inet.jortho.AutoSpellChecker.insertUpdate(AutoSpellChecker.java:125)
	at javax.swing.text.AbstractDocument.fireInsertUpdate(java.desktop@13.0.1/Unknown Source)
	at javax.swing.text.AbstractDocument.handleInsertString(java.desktop@13.0.1/Unknown Source)
	at javax.swing.text.AbstractDocument.insertString(java.desktop@13.0.1/Unknown Source)
	at javax.swing.text.PlainDocument.insertString(java.desktop@13.0.1/Unknown Source)
	at javax.swing.text.AbstractDocument.replace(java.desktop@13.0.1/Unknown Source)
	at javax.swing.text.JTextComponent.setText(java.desktop@13.0.1/Unknown Source)
	at se.datadosen.explorer.DetailsEditor$ReadOnlyField.refresh(DetailsEditor.java:124)
	at se.datadosen.explorer.DetailsEditor.refresh(DetailsEditor.java:207)
	at se.datadosen.explorer.JAlbumObject.lambda$render$1(JAlbumObject.java:332)
	at se.datadosen.explorer.JAlbumObject$$Lambda$700/0x000000080090ac40.call(Unknown Source)
	at java.util.concurrent.FutureTask.run(java.base@13.0.1/Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@13.0.1/Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@13.0.1/Unknown Source)
	at java.lang.Thread.run(java.base@13.0.1/Unknown Source)
I think these two threads deadlock each other. The shared "monitor" here is 0x0000000708fbb8d0. To solve the problem I probably need to pass the JTextComponent.setText call to the AWT thread. I'll adjust this and pass you an update to test!
davidekholm

Posts: 3,192
Registered: 18-Oct-2002
Re: jA 20 freezes in Detail view
Posted: 18-Apr-2020 21:45   in response to: davidekholm in response to: davidekholm
Correct
  Click to reply to this thread Reply
Please perform a core update to 20.0.4 now (Tools->External tools->jAlbum core update).
MarkusD

Posts: 515
Registered: 13-Apr-2006
Re: jA 20 freezes in Detail view
Posted: 19-Apr-2020 00:32   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
Please perform a core update to 20.0.4 now (Tools->External tools->jAlbum core update).
Bingo! Problem solved. ;-)

Scrolling to my lengthy comments is as fast as hell, wow, cool. :-)

Thanks again, Markus
jGromit

Posts: 6,825
Registered: 31-Jan-2006
Re: jA 20 freezes in Detail view
Posted: 19-Apr-2020 00:45   in response to: MarkusD in response to: MarkusD
 
  Click to reply to this thread Reply
MarkusD wrote:
Scrolling to my lengthy comments is as fast as hell, wow, cool. :-)

Would that reading them were as painless.
MarkusD

Posts: 515
Registered: 13-Apr-2006
Re: jA 20 freezes in Detail view
Posted: 19-Apr-2020 08:36   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
jGromit wrote:
MarkusD wrote:
Scrolling to my lengthy comments is as fast as hell, wow, cool. :-)

Would that reading them were as painless.

It is like in the analogue world. You don't have to read that lengthy boring foreword in the book, just skip it and dive right into the first chapter. ;-)

I'm creating my albums for my own pleasure in the first place. If someone else likes it or not is not important to me. Writing down what I have done even month before a journey is like a log book to find out when did I start last time to check when that ferry crossing was able to book online or when did that sale for the festival pass start.
karlmistelberger

Posts: 214
Registered: 5-Dec-2013
Re: jA 20 freezes in Detail view
Posted: 19-Apr-2020 08:43   in response to: MarkusD in response to: MarkusD
 
  Click to reply to this thread Reply
MarkusD wrote:
Scrolling to my lengthy comments is as fast as hell, wow, cool. :-)

You may give it another try. I pasted full contents of https://bugzilla.suse.com/attachment.cgi?id=836008 into the folder description and yes, jAlbum built Sample Portfolio and internal preview worked correctly.
MarkusD

Posts: 515
Registered: 13-Apr-2006
Re: jA 20 freezes in Detail view
Posted: 19-Apr-2020 12:45   in response to: karlmistelberger in response to: karlmistelberger
 
  Click to reply to this thread Reply
karlmistelberger wrote:
MarkusD wrote:
Scrolling to my lengthy comments is as fast as hell, wow, cool. :-)

You may give it another try. I pasted full contents of https://bugzilla.suse.com/attachment.cgi?id=836008 into the folder description and yes, jAlbum built Sample Portfolio and internal preview worked correctly.

For me the problem is solved, no need to test any more. Nevertheless it would be interesting to know from David what really triggered that problem. To my understanding it had nothing to do with the amount of text in a comment.
davidekholm

Posts: 3,192
Registered: 18-Oct-2002
Re: jA 20 freezes in Detail view
Posted: 19-Apr-2020 19:51   in response to: MarkusD in response to: MarkusD
 
  Click to reply to this thread Reply
MarkusD wrote:

For me the problem is solved, no need to test any more. Nevertheless it would be interesting to know from David what really triggered that problem. To my understanding it had nothing to do with the amount of text in a comment.

Yes and no. The amount only triggered a bug that was already existing but dormant because the amount of text changed the timing of certain operations.

The core problem was that two threads where deadlocking each other. We had the main UI thread (the "AWT" thread) trying to do some painting/animation to a UI component at the same time that a metadata loader thread tried to update it (change its text). I assume that these two threads locked the same UI resources, but in different order, thereby causing a deadlock. I can see a hint of this as they both tried to lock the same "monitor". A monitor is a device that controls unique access to a shared resource. Compare with the occupied/free sign on the toilet of an airplane.

Here's a typical deadlock scenario that's rather intuitive to understand:
Imagine two mechanics (the two threads) working on their own cars, but they share the same tool box (in our case the user interface components are shared). Now imagine that the first mechanic grabs the screwdriver and the second grabs the wrench. All is fine so far. Now imagine that the first mechanic also needs the wrench, so he waits for it to be returned to the tool box. Now imagine the second mechanic (the one holding the wrench) realizing he also needs the screwdriver, so he waits for it to be returned to the tool box. These two mechanics now "deadlock" each other. They will wait forever unless one of them politely "backs out" and returns his tool to retry later.

There are many different ways to handle these scenarios. Either one can have a device that detects deadlock and makes one party back out or one tries to avoid the deadlock to happen altogether. You can for instance avoid shared resources (give each mechanic their own unique tool boxes) or set up a policy dictating in what order shared resources are to be reserved, or dictate that one is to grab and return the whole tool box for every operation, but that hurts concurrency (increases overall waiting time). A forth solution could be for one mechanic to hand over the work involving shared tools to a dedicated mechanic ("Everyone lets Tom change the tyres"). It is this last approach that's dictated by Java's UI framework Swing. In Swing, UI components should only be manipulated from the AWT thread. In an earlier jAlbum 20 beta I was actually loading the file metadata and updating the UI components from the AWT thread, but this was slow as it only utilized one CPU core. Furthermore this made scrolling feel sluggish. I then fixed this to use multiple background threads for reading metadata, but forgot to ensure that they passed the result over to the AWT thread when finally updating the comment text field component for instance.

Before the change, the code looked like this:

Metadata loader thread:
comp.setText(originalText); // Oops, doing this from a background thread is not allowed

The fixed code hands over the updating to the AWT thread like this:

Metadata loader thread:
SwingUtilities.invokeLater(() -> comp.setText(originalText));


I hope you enjoyed this little lecture :-). I find multi threaded issues both tricky and fascinating. Tricky because one cannot always reproduce them (they are timing sensitive). Fascinating because we actually encounter and tackle the same kind of problems in our everyday lives, usually even without thinking about it. In the computer world we simply pick among solutions from the real world.
MarkusD

Posts: 515
Registered: 13-Apr-2006
Re: jA 20 freezes in Detail view
Posted: 20-Apr-2020 19:03   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
...
I hope you enjoyed this little lecture :-).
Yes. Thanks for a view behind the scenes. ;-)
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums