Bug 118723 - Key events can be handled in wrong order by Basic scripts
Summary: Key events can be handled in wrong order by Basic scripts
Status: RESOLVED INSUFFICIENTDATA
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.4.7.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-12 12:39 UTC by Alex Fedorov
Modified: 2019-08-19 07:05 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
test script (774 bytes, application/x-wine-extension-vbs)
2018-07-12 12:39 UTC, Alex Fedorov
Details
input_mangle.vbs (762 bytes, application/x-wine-extension-vbs)
2018-07-19 17:18 UTC, Alex Fedorov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Fedorov 2018-07-12 12:39:41 UTC
Created attachment 143516 [details]
test script

Problem: 
Key events appear to be handled in last in-first out order in VBS scripts that are executed by LO Writer. 
This can change the order in which input events are handled, which in turn makes input handling very performance-sensitive and can break certain macros and extensions that rely on input. 
For example, in vibreoffice extension (an attempt to emulate vi in LibreOffice) such handling causes occasional character swaps during fast typing in "insert" mode. Streamlining the corresponding script code path alleviates this problem somewhat, but does not remove it completely.

Steps to reproduce:
Use attached script, add it to Writer and run reg() subroutine. This will install key events handler, which does not consume key press events, but takes 2 seconds to process an "a" key press event.
Open new document and type "as".

Observed behaviour:
It will output "s", wait approximately 2 seconds, and output "a".

Expected behaviour:
Wait 2 seconds and output "as" at once.

Version: 5.4.7.2
OS: All
Comment 1 Buovjaga 2018-07-18 14:10:07 UTC
How can I add the .vbs file?

Set to NEEDINFO.
Change back to UNCONFIRMED after you have provided the information.
Comment 2 Alex Fedorov 2018-07-19 17:15:41 UTC
What I meant by adding a script was basically creating a new LO Basic module and pasting script contents in it.

Assuming the user interface of LO is in English, here is the procedure.
Invoke the "LibreOffice Basic Macros" dialog: click Tools > Macros > Organize Macros > LibreOffice Basic... .
Add new module: click Organizer... > Modules tab > New... > (enter module name) > Ok > Close . This will show "LibreOffice Basic Macros" dialog again.
Edit the created module: select the created module in "Macro from" field of the "LibreOffice Basic Macros" dialog and click Edit. This will show LibreOffce Basic IDE.
Remove default module contents (the empty Main sub) and paste contents of the vbs script attached to the ticket.

To run the script, select reg() function and click "Run Basic" button.

Further information about LO Basic IDE can be found, i.e, at https://help.libreoffice.org/Basic/Integrated_Development_Environment_IDE
Comment 3 Alex Fedorov 2018-07-19 17:18:27 UTC
Created attachment 143650 [details]
input_mangle.vbs

Script that demonstrates input mangling caused by delay in function that handles key press events.
Comment 4 Alex Fedorov 2018-07-19 17:20:16 UTC
I have attached input_mangle.vbs script that demonstrates input mangling more clearly.

Key press event handler (KeyHandler1_KeyPressed(oEvent) function) just logs input, waits 100 ms and returns; it does not consume input. Logged input can be displayed by pressing the "=" key.
The problem is that, even if the input is passed to the handler in the correct order (see input log to verify this), the delay in key press handler causes LO to print characters entered by the user in entirely wrong order.

Steps to reproduce:
Create a new module, paste script contents and run reg1() sub.
Try to print something. Observe, that the output is wrong. In my case, typing "the quick brown fox" printed "hte qiukc brwon fox". 
Press "=" to display the input log (in my case: "the quick brown fox"). Observe, that logged input is in the correct order.
Comment 5 Xisco Faulí 2019-01-17 12:08:59 UTC
A new major release of LibreOffice is available since this bug was reported.
Could you please try to reproduce it with the latest version of LibreOffice
from https://www.libreoffice.org/download/libreoffice-fresh/ ?
I have set the bug's status to 'NEEDINFO'. Please change it back to
'UNCONFIRMED' if the bug is still present in the latest version.
Comment 6 QA Administrators 2019-07-17 02:49:52 UTC Comment hidden (obsolete)
Comment 7 QA Administrators 2019-08-19 07:05:13 UTC
Dear Alex Fedorov,

Please read this message in its entirety before proceeding.

Your bug report is being closed as INSUFFICIENTDATA due to inactivity and
a lack of information which is needed in order to accurately
reproduce and confirm the problem. We encourage you to retest
your bug against the latest release. If the issue is still
present in the latest stable release, we need the following
information (please ignore any that you've already provided):

a) Provide details of your system including your operating
   system and the latest version of LibreOffice that you have
   confirmed the bug to be present

b) Provide easy to reproduce steps – the simpler the better

c) Provide any test case(s) which will help us confirm the problem

d) Provide screenshots of the problem if you think it might help

e) Read all comments and provide any requested information

Once all of this is done, please set the bug back to UNCONFIRMED
and we will attempt to reproduce the issue. Please do not:

a) respond via email 

b) update the version field in the bug or any of the other details
   on the top section of our bug tracker

Warm Regards,
QA Team

MassPing-NeedInfo-FollowUp