Explorer Preview handler may hang Lister. Is there a way to avoid it?

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Slavic
Senior Member
Senior Member
Posts: 290
Joined: 2006-02-26, 15:41 UTC
Location: Montenegro

Explorer Preview handler may hang Lister. Is there a way to avoid it?

Post by *Slavic »

This is not a typical bugreport, even if it looks alike, but my thoughts and question.

After a lot of different tests of Lister in TC 10 beta I saw the cases when Explorer Preview may hang, making Lister and TC non-responsive. Here it a simplified test example and explanation.

testdoc.htm

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html> 
<body>
<p>Test page</p>
</body>
</html>
This is a very simple web page created according to XHTML 1.1 standard (XHTML is used quite rarely nowadays in favour of HTML5). The distinctive feature of XHTML is the first line describing it as XML document according to a general idea that XHTML is a particular case of XML with specific document type definition (DTD). DTD is defined by link to w3.org website. In a web browser or in Lister with default settings this file is shown without any problem; Lister detects it as HTML and removes all tags, showing only a single paragraph, as supposed.

The difficulty begins when we try to open this file in MS Word, in my case it's Word 2013. Rename the file to testdoc.doc and double-click it. Word refuses to open it, showing the warning instead; you can expand and see the explanation. The reason behind this is security measures, which block any external (web) links in XML file because they may be potentially dangerous. So, you cannot open this document in MS Word for view or edit, this blocking is intentionally designed by Word developers. But this is not a great problem yet.

Now try to open the renamed file testdoc.doc in Lister. It still shows it as HTML document with UTF-8 encoding, thanks to format autodetection. Now try to switch Lister to Explorer Preview mode (8). Lister hangs and TC becomes non-responsive. You can launch the Task Manager and see the Microsoft Word in the Apps list; it doesn't show a window and cannot be interacted. The only option is to end this task in Task Manager menu. After that Lister will show the file content as binary (2), counting this as a handler failure, and TC becomes responsive again.

This is obviously not a TC bug, it's a design flaw of MS Word as external preview program, when it doesn't show a warning which is visible in normal mode and doesn't have any window to interact with, it simply hangs and is hanging the call chain: Lister and TC. As a result, it's not possible to restore TC using its own controls.

I think that at some point of TC development it would have sense to foresee such situations and find some solution. Maybe it's possible to call an external handler as a separate process, which in the case of failure will not hang or crash Lister and TC. Then, if external handler does not respond for reasonable time, terminate it. Or maybe there are some other solutions available right now, like creating an intermediate layer or simply using a different preview mode. If someone can suggest a solution, please add it here.

NB: I didn't have any intention to hang your TC using the test above, but it's an inevitable side effect; it should not crash a whole OS. Please don't use TC for other actions during the test. Anyway, please accept my apologies.
Desktop: Windows 11 Pro 23H2, TC 11.03(RC). Mobile: Pixel 5a, Android 14, TC 3.42b5
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Explorer Preview handler may hang Lister. Is there a way to avoid it?

Post by *ghisler(Author) »

What happens in Explorer when you enable the preview there?

I ask because I don't get any hang in Windows 10, but I don't have MS Office installed.
Author of Total Commander
https://www.ghisler.com
Slavic
Senior Member
Senior Member
Posts: 290
Joined: 2006-02-26, 15:41 UTC
Location: Montenegro

Re: Explorer Preview handler may hang Lister. Is there a way to avoid it?

Post by *Slavic »

ghisler(Author) wrote: 2021-04-30, 14:01 UTC What happens in Explorer when you enable the preview there?
The reasonable question!
I should have tested it and compare before, but... OK, the results:

1. Open the Explorer window, show the Preview pane using View menu or Alt+P. Image: https://prnt.sc/12bah6l At the same time, open Task Manager, Process tab to see current active apps.
2. Navigate to test directory and point to testdoc.doc. Image: https://prnt.sc/12baie7
3. Microsoft Word arrives at the apps list in Task Manager without its window; Explorer shows empty preview pane, but remains responsive.
4. Moving the Explorer out of central screen area opens the small Microsoft Word panel behind it (this panel doesn't have a corresponding button on the Windows taskbar). It's possible to click "Details" and see the explanation of the error. Image: https://prnt.sc/12bajkw
5. Clicking "OK" opens the empty Word window without any menu and other controls, only with window buttons in the top right corner. Image: https://prnt.sc/12bal40
6. Explorer preview pane now shows the text: "This file can't be previewed because of an error in the Microsoft Word previewer." Image: https://prnt.sc/12bam2g
7. Empty Word window can be closed by [x] and it disappears in the Task Manager. Text on the Explorer preview pane remains as is.
During all these operations, Explorer window remains responsive and can be freely moved on the desktop or closed.

Very important: I repeated the test from initial post, but moved TC and Lister windows to peripheral areas. The small Word panel with warning is visible now on the screen near the central area, as in (4). It's possible now to click "OK", close the empty Word and restore TC without Task Manager. But the hang of TC and Lister didn't allow to move their windows out of central area.

P.S. I just remembered that Explorer UI works in a separate thread, so it's not easy to hang it because of failure in programs and most of drivers. Apparently TC uses the same thread for external handler. Could creating a new thread keep TC UI responsive and fix this bug?
Last edited by Slavic on 2021-04-30, 16:03 UTC, edited 1 time in total.
Desktop: Windows 11 Pro 23H2, TC 11.03(RC). Mobile: Pixel 5a, Android 14, TC 3.42b5
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Explorer Preview handler may hang Lister. Is there a way to avoid it?

Post by *Usher »

Slavic wrote: 2021-04-29, 20:31 UTCI think that at some point of TC development it would have sense to foresee such situations and find some solution.
You cannot foresee all possible problems. The same preview may work OK in some Office versions and be broken by some poorly tested MS updates.
For me the simplest and probably the most universal solution is to add exclusions to "Define view method by file type" in Lister. Currently you can only add more supported file extensions, but you cannot exclude any.
Andrzej P. Wozniak
Polish subforum moderator
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Explorer Preview handler may hang Lister. Is there a way to avoid it?

Post by *ghisler(Author) »

Very important: I repeated the test from initial post, but moved TC and Lister windows to peripheral areas. The small Word panel with warning is visible now on the screen near the central area, as in (4). It's possible now to click "OK", close the empty Word and restore TC without Task Manager. But the hang of TC and Lister didn't allow to move their windows out of central area.
Maybe you could use Alt+Tab to switch to the small warning window?
Author of Total Commander
https://www.ghisler.com
Slavic
Senior Member
Senior Member
Posts: 290
Joined: 2006-02-26, 15:41 UTC
Location: Montenegro

Re: Explorer Preview handler may hang Lister. Is there a way to avoid it?

Post by *Slavic »

ghisler(Author) wrote: 2021-05-02, 08:32 UTC Maybe you could use Alt+Tab to switch to the small warning window?
Yes, it's possible. It is shown in the task list as "Microsoft Word", and switching to it shows that small window on top of others (TC and Lister in particular). Then pressing "OK" shows the empty Word window, which can be closed and Lister returns to normal state. It's, however, a bit unobvious way because Word isn't shown on the taskbar. MS developers should have shown this task, maybe they decided that it's a rare case, maybe simply missed it.

From Lister's point, it looks like a dialog MessageBox() which by design blocks its parent windows, but the problem is, it's not on the top position as a modal window should be. I can only guess whether it's possible to move it on the top programmatically, but in theory it would be a good solution.
Desktop: Windows 11 Pro 23H2, TC 11.03(RC). Mobile: Pixel 5a, Android 14, TC 3.42b5
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Explorer Preview handler may hang Lister. Is there a way to avoid it?

Post by *ghisler(Author) »

I don't think that there is anything I could do here. Maybe load the Explorer extension in a background thread, but this is also problematic because these OLE objects are usually not thread safe.
Author of Total Commander
https://www.ghisler.com
Slavic
Senior Member
Senior Member
Posts: 290
Joined: 2006-02-26, 15:41 UTC
Location: Montenegro

Re: Explorer Preview handler may hang Lister. Is there a way to avoid it?

Post by *Slavic »

Yes, it's a good solution to make the behaviour like Explorer, which remains interactive even when external handler is waiting for user's input. I don't expect this soon, maybe in the future because as I guess need to do some tests of different approaches. If it's possible at all, of course.

Well, this is more a suggestion rather than an urgent bug to fix. Please move this thread to "Suggestions".
Desktop: Windows 11 Pro 23H2, TC 11.03(RC). Mobile: Pixel 5a, Android 14, TC 3.42b5
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Explorer Preview handler may hang Lister. Is there a way to avoid it?

Post by *Hacker »

Moderator message from: Hacker

Moved to Suggestions.
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Post Reply