Bug 146007 - FilePicker dialog execute method hangs LibreOffice
Summary: FilePicker dialog execute method hangs LibreOffice
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.2.0.1 rc
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:7.4.0 target:7.3.4
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2021-12-02 11:18 UTC by Julian Ragan
Modified: 2022-05-06 11:23 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Test File Picker (9.30 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-12-02 11:18 UTC, Julian Ragan
Details
Writer version (10.30 KB, application/vnd.oasis.opendocument.text)
2021-12-02 11:18 UTC, Julian Ragan
Details
Callstacks for recent LO build in file open scenarios (including macro in IDE) (12.09 KB, text/plain)
2022-04-30 19:54 UTC, Matt K
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Ragan 2021-12-02 11:18:07 UTC
Created attachment 176648 [details]
Test File Picker

When file picker dialog created using:

CreateUnoService("com.sun.star.ui.dialogs.FilePicker")

is executed, LibreOffice hangs (CPU usage is at 0% in task manager). Dialog itself is not made visible.

Please see one of the attached files with test macros, this was tested with Calc and Writer.

Tested with 7.2.0.1, 7.2.0.4 and 7.2.3.2 (version info below)

Version: 7.2.3.2 (x64) / LibreOffice Community
Build ID: d166454616c1632304285822f9c83ce2e660fd92
CPU threads: 8; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win
Locale: pl-PL (pl_PL); UI: pl-PL
Calc: CL

Version 7.1.3.2 and 7.0.6.2 worked without hanging.
Comment 1 Julian Ragan 2021-12-02 11:18:51 UTC
Created attachment 176649 [details]
Writer version
Comment 2 Andreas Heinisch 2021-12-28 21:44:36 UTC
Confirmed in:

Version: 7.4.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: cfbcbb605dbaaea45dc9ac5ea792d72cb2f2c1bb
CPU threads: 6; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-US
Calc: CL

Does not hang in:
Version: 7.1.0.3 (x64) / LibreOffice Community
Build ID: f6099ecf3d29644b5008cc8f48f42f4a40986e4c
CPU threads: 6; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-US
Calc: CL
Comment 3 Andreas Heinisch 2021-12-28 21:54:33 UTC
Remark: If the macro is executed directly in the Basic IDE, the macro never hangs.
Comment 4 Felix Koehler 2022-04-26 14:15:58 UTC
Another workaround is using the OfficeFilePicker directly in your code or as a preference:

Extras/Options -> Libreoffice: Dialogs for Open/Save [x] Use office dialogs

This is a blocker for version update for us, as we need the preview from the Windows FilePicker in some automation use cases.
Comment 5 Andreas Heinisch 2022-04-29 16:51:23 UTC
This seems to have begun at the below commit.
Adding Cc: to Matt K and Mike Kaganski; Could you possibly take a look at this one? Thank you!

commit 1c1226709c6be39c5462f5e6e1262ca630b30b34
author	Matt K <mattkse@gmail.com>	Wed Apr 21 17:34:16 2021 -0500
committer	Mike Kaganski <mike.kaganski@collabora.com>	Thu Apr 22 22:20:55 2021 +0200
tree 14dc0f683da5bc6c8e08ea7db516da174960679f
parent 04bd21d483c33c5011e31ac12d02c9e00dc410ce
tdf#106282 Change Windows File Dialog to run on the main thread | https://gerrit.libreoffice.org/c/core/+/114482
 c2e223873620c4d44247c835aff279053f574dc6 is the first bad commit
commit c2e223873620c4d44247c835aff279053f574dc6
Author: Norbert Thiebaud <nthiebaud@gmail.com>
Date:   Thu Apr 22 13:29:23 2021 -0700

    source 1c1226709c6be39c5462f5e6e1262ca630b30b34

    source 1c1226709c6be39c5462f5e6e1262ca630b30b34
Comment 6 Matt K 2022-04-29 19:49:35 UTC
(In reply to Andreas Heinisch from comment #5)
> Adding Cc: to Matt K and Mike Kaganski; Could you possibly take a look at
> this one? Thank you!

I took a quick look and it seems like the main thread is blocked waiting for something to happen.  I'm not familiar with how macros use (or don't) the main thread, but if the main thread is blocked before the file picker opens it could just be an endless wait situation/deadlock.  Haven't debugged enough to say more or suggest a solution.
Comment 7 Matt K 2022-04-30 19:54:43 UTC
Created attachment 179869 [details]
Callstacks for recent LO build in file open scenarios (including macro in IDE)
Comment 8 Matt K 2022-04-30 19:57:28 UTC
I've attached a file with the callstacks for normal file open scenarios.

It looks like we could change the "macro in app" path to use reflection just as is done in the IDE callstack which also happens on the main thread.

There may be a easier solution but I can't seem to get a build of LO with symbols with the old behavior to see what we were doing before and see what changed.  I tried checking out a tag on git and downloading an archived version, but can't get any symbols working yet.
Comment 9 Matt K 2022-05-04 16:02:31 UTC
I looked further and I'm seeing that the latest version hangs when clicking on the macro, but when I look at it in the debugger it doesn't hang and works as expected.  Must be some kind of timing issue or something related to how UNO works in dispatching.

It's also worth noting that the macro causes the file picker to be opened on a background thread, but surprisingly it doesn't crash when cancelling a long running search operation as it was before bug 106282 was fixed.
Comment 10 Commit Notification 2022-05-05 09:58:30 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/b8bb44161aeb6e00526a38343b63e678ce7d4a1a

tdf#146007: make sure to not hold solar mutex

It will be available in 7.4.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2022-05-06 11:23:53 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/e5bd911b01d9437841e2ec59a233ce6a6baa4dbf

tdf#146007: make sure to not hold solar mutex

It will be available in 7.3.4.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.