Bug 165763 - After adding a toolbar item, saving apparently hangs
Summary: After adding a toolbar item, saving apparently hangs
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.0.0.3 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, haveBacktrace, perf, regression
Depends on:
Blocks: Save Calc-Toolbars
  Show dependency treegraph
 
Reported: 2025-03-15 20:14 UTC by studog
Modified: 2026-05-21 18:43 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Example test case, broken (1.02 MB, application/vnd.oasis.opendocument.spreadsheet)
2025-03-15 20:16 UTC, studog
Details
Perf flamegraph of saving (1.05 MB, image/svg+xml)
2026-02-04 21:14 UTC, Buovjaga
Details

Note You need to log in before you can comment on or make changes to this bug.
Description studog 2025-03-15 20:14:08 UTC
Description:
This one is strange, please read the whole report.

I have an ODS file. I once upon a time made a custom toolbar and stored it in the ODS file. I wanted to update the toolbar so I deleted it, re-created it, stored in the ODS file, and have been re-adding items.  
  
First I re-added the "About" item and the ODS saves fine.

Adding the next item causes saving to apparently hang. Turns out it's not hung, it just takes a _long_ time.

Doing a test save of a random change saves in a reasonable amount of time.

So the problem is that, a save after adding a toolbar item to a customer toolbar stored in the ODS takes _much_ longer than it should.

Steps to Reproduce:
# Prelude
1. Reset user profile by moving ~/.config/libreoffice/4/user to ~/.config/libreoffice/4/user-backup
2. Open Calc with no file
3. Set macro security to Medium: Tools -> Options -> LibreOffice -> Security -> Macro Security -> Medium
4. Close Calc

# Get example file
5. Download the attached example file
6. Make two copies

# When opening the example files, you'll have to "Enable macros". Doing these steps with macros disabled does not reproduce the problem.
# Please do not trust me/the downloads! Check the macros before enabling them. There's nothing untoward, but better safe than sorry.

# A "reasonable" save
7a. Open one copy, sheet 'Summaryo' should be selected.
7b. Type 'a' in cell A1
7c. Save
7d. Observe that the save proceeds in a reasonable amount of time: I timed this at around 0:07. (This isn't really reasonable actually, saving should be pretty close to instant, but that's a different bug.)

# A "hung" save
8a. Open the other copy
8b. Tools -> Customize -> Toolbars
8c. Scope -> Holdings--save-hang-blank.ods
8d. Target -> HoldingsBar
8e. Category -> Macros
8f. Available Commands -> Holdings--save-hang-blank.ods :: Standard :: Module1 :: Create_Blank
8g. Click the Add Item button to add Create_Blank to the Assigned Commands list, it should be the second item after "About LibreOffice"
8h. Ok
8i. Observe that the custom toolbar now has a text entry "Create_Blank"
8j. Save the ODS
8k. Observe that the save takes an unreasonable amount of time: I timed this at around 1:42.

# Removing sheets from the example speeds up the save, until the "hung" case is reasonable when there's about 1 - 4 sheets remaining.
# So this is dependent on the macros, and the number of sheets.

Actual Results:
Saving takes a very long time; long enough most users will consider Calc to have hung, and kill it.



Expected Results:
Save is as fast in the "hung" case as in the "reasonable" case. There's no reason that changing the toolbar should have this kind of effect.


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Version: 24.8.4.2 (X86_64) / LibreOffice Community
Build ID: 480(Build:2)
CPU threads: 16; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: en-US (C.UTF-8); UI: en-US
Ubuntu package version: 4:24.8.4~rc2-0ubuntu0.24.04.1~lo1
Calc: threaded


At least it's not really hung, so one can just wait it out. A regular user isn't likely to do that though.
  
I suspect that something with the toolbar-change-save is being done, incorrectly, on a per-sheet basis.

When setting up the example for reproduction purposes, I thought I should remove the python macros too, since they didn't seem to be involved. While doing this I discovered that the Update button on the Summaryo sheet had a python macro bound to the "Mouse button pressed" event, from long ago testing. My initial timing of the "hung" case was 3:04; after removing that event binding the problem dropped to the reported 1:42.
The point here is that whatever is wrong with the toolbar-change-save is also probably wrong with the form-controls-save.
Comment 1 studog 2025-03-15 20:16:02 UTC
Created attachment 199832 [details]
Example test case, broken
Comment 2 studog 2025-07-31 18:40:41 UTC
Part of the problem is the experience the end user receives: the save progress bar appears immediately and then nothing happens for a long long time.

Reproduced, timed at 1:36, on:

Version: 25.2.5.2 (X86_64) / LibreOffice Community
Build ID: 520(Build:2)
CPU threads: 16; OS: Linux 6.11; UI render: default; VCL: gtk3
Locale: en-US (C.UTF-8); UI: en-US
Ubuntu package version: 4:25.2.5~rc2-0ubuntu0.24.04.1~lo1
Calc: threaded
Comment 3 studog 2025-07-31 18:48:52 UTC Comment hidden (obsolete)
Comment 4 studog 2025-08-09 14:23:15 UTC Comment hidden (obsolete)
Comment 5 Buovjaga 2026-02-04 21:14:12 UTC
(In reply to studog from comment #0)
> # A "hung" save
> 8a. Open the other copy
> 8b. Tools -> Customize -> Toolbars
> 8c. Scope -> Holdings--save-hang-blank.ods
> 8d. Target -> HoldingsBar
> 8e. Category -> Macros
> 8f. Available Commands -> Holdings--save-hang-blank.ods :: Standard ::
> Module1 :: Create_Blank
> 8g. Click the Add Item button to add Create_Blank to the Assigned Commands
> list, it should be the second item after "About LibreOffice"
> 8h. Ok
> 8i. Observe that the custom toolbar now has a text entry "Create_Blank"
> 8j. Save the ODS
> 8k. Observe that the save takes an unreasonable amount of time: I timed this
> at around 1:42.

Repro on Linux and Windows. After the file has been saved, reloading and saving again is quick.

Saving used to take only about 5 secs, but then came the new Customize dialog: https://wiki.documentfoundation.org/ReleaseNotes/6.0#Dialogs

I bibisected with linux-64-6.0 repo.

With this commit we could no longer assign a macro: d69f9436b59e249af8dcac88ccadf09b920b1bab
Convert UI of Customize Dialog to the new design

This commit restored the ability, but the long saving time was already apparent: 3b12778af71951bfce321c73509e8b0c59b02853
tdf#112207: Allow assigning macros to ui elements

I'm not sure, if anything in the dialog revamp itself could have caused this, or if it just masks a bug introduced within the period when it was impossible to add macros to toolbars.
Comment 6 Buovjaga 2026-02-04 21:14:39 UTC
Created attachment 205365 [details]
Perf flamegraph of saving

Took a perf trace of several seconds of saving.