View Issue Details

IDProjectCategoryView StatusLast Update
0033705LazarusLCLpublic2018-07-31 15:01
Reporterkpp Assigned ToMichl  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformWindows 64 ยง2 Bit ApplicationOS10 
Product Version1.8.2 
Summary0033705: Program starts slowly
DescriptionA Program that has a lot of pagecontrols and different tabsheets.
1 frame 5 times in different tabsheets.
Under Windows 10 (version 1709) the program opens in under 1 second.
Under Windows 10 (version 1803) it takes about 30 seconds after leaving FormCreate until the mask opens.
When I throw out the tabsheets, it's getting faster.
TagsNo tags attached.
Fixed in Revision58448
LazTarget1.10
WidgetsetWin32/Win64
Attached Files

Relationships

has duplicate 0033923 closedMichl Behavior of EnableWindow since last MS Upgrades 
related to 0034018 closedMichl LCL: Regression from r58448 & r58497 

Activities

kpp

2018-05-07 13:41

reporter  

W10Test.zip (140,827 bytes)

Pascal Riekenberg

2018-05-07 13:54

developer   ~0108173

Confirmed!
Also noticed a slowdown in opening "Options" in Lazarus between 1709 and 1803.

Janusz Tomczak

2018-05-07 21:44

reporter   ~0108182

I found a similar case
https://www.reddit.com/r/Windows10/comments/8hht7s/windows_10_april_update_performance_problems/

wp

2018-05-07 23:25

developer   ~0108186

Please don't post sample projects which have requirements of third-party packages, rxnew here. Fortunately W10Test seems to contain only left-overs from an older version. Therefore, it is enough to remove "rxnew" from the project requirements and unit "curredit" from the uses line of unit "Frame1pas" in order to be able to compile and run the demo.

kpp

2018-05-08 07:41

reporter  

W10testV2.zip (140,819 bytes)

kpp

2018-05-08 07:43

reporter   ~0108191

You can delete then "curedit" in the source or use the new attachment
Sorry.

Pascal Riekenberg

2018-05-12 06:11

developer   ~0108243

Confirmed on a second machine running 1803 now.

kpp

2018-05-14 08:18

reporter   ~0108277

With the Windows patch KB 4103721 it will be a little faster instead of 30s only 20s

kpp

2018-05-28 13:34

reporter   ~0108558

I have tried again with the Lazarus version 1.8.4.
there is no change, it still takes an extremely long time until the program opens.

jamie philbrook

2018-05-28 17:58

reporter   ~0108561

Turning off Themes will allow me to start that code without debugging
in 0000007:0000007 secs

also I make sure the debugger is using external file.

and also I too notice a slow down with the OPTIONS when opening since
windows update.

kpp

2018-05-29 08:30

reporter   ~0108569

Confirmed, without themes, it starts much faster

kpp

2018-05-29 10:05

reporter   ~0108572

quantified:
Version 1709: 0s
Version 1803 with Themes: 20s
Version 1803 without Themes: 8s
but still slow

Pascal Riekenberg

2018-06-13 12:08

reporter   ~0108887

With the Windows patch KB4284835 it's getting worse. Takes 80s now!

And: Lazarus "Options" take about 7s to open now!

BrunoK

2018-06-25 17:00

reporter  

win32.patch (1,505 bytes)   
Index: win32proc.pp
===================================================================
--- win32proc.pp	(revision 58287)
+++ win32proc.pp	(working copy)
@@ -162,6 +162,7 @@
     wv8,
     wv8_1,
     wv10,
+    wv10ge17134,       // ~bk build number >= 17134 #bug 0033705
     wvLater
   );
 
@@ -1655,7 +1656,12 @@
     end;
     10: begin
      case Win32MinorVersion of
-       0: WindowsVersion := wv10;
+       0: begin
+            if Win32BuildNumber<17134 then   // ~bk #bug 0033705
+              WindowsVersion := wv10
+            else
+              WindowsVersion := wv10ge17134;
+       end
      else
        WindowsVersion := wvLater;
      end;
Index: win32winapi.inc
===================================================================
--- win32winapi.inc	(revision 58287)
+++ win32winapi.inc	(working copy)
@@ -1222,7 +1222,13 @@
  ------------------------------------------------------------------------------}
 function TWin32WidgetSet.EnableWindow(HWnd: HWND; BEnable: Boolean): Boolean;
 begin
-  Result := Boolean(Windows.EnableWindow(HWnd, BEnable));
+  if WindowsVersion<>wv10ge17134 then
+    Result := Boolean(Windows.EnableWindow(HWnd, BEnable))
+  else // ~bk potential solution for a change in windows 10 of EnableWindow #bug 0033705
+    if IsWindowEnabled(HWnd)<>BEnable then
+      Result := Boolean(Windows.EnableWindow(HWnd, BEnable))
+    else
+      Result := False;
 end;
 
 {------------------------------------------------------------------------------
win32.patch (1,505 bytes)   

BrunoK

2018-06-25 17:00

reporter   ~0109046

Since I suffer the same problems, I have searched what causes it.

I suspect that Windows.EnableWindow(HWnd, BEnable) did previously check that the Enabled state was really changing.
It seems not to be doing so any more and thus sends a huge number of WM_ENABLE messages with all the overhead it generates in win32callbak.inc. (When I say huge, it is like after auditing the 10'000 first message in create form, there where > 3000 WM_ENABLE messages). Now it is back to same number as in windows XP, that is <10 for the same program.

The attached patch is experimental. In unit Win32Proc, you might try to modify the "Win32BuildNumber<17134" to some other BuildNumber as a minimal limit.
Maybe in win32winapi.inc TWin32WidgetSet.EnableWindow, the IsWindowEnabled(HWnd)<>BEnable could be generalized.

Succinctly also tested W10 program with these change on Windows XP and it hasnt yet failed.

The patch also address successfully the Lazarus "Options" slowness.

Pascal Riekenberg

2018-06-25 20:26

reporter   ~0109047

Last edited: 2018-06-26 06:21

View 2 revisions

I also noticed the huge amount of messages when starting to dig into the problem but didn't manage to find the root cause. I'll test you patch later. Thanks for the effort!

Pascal Riekenberg

2018-06-26 06:37

reporter   ~0109057

Patch solves my issues!

BrunoK

2018-06-26 09:07

reporter   ~0109064

@Pascal Riekenberg

Consider submitted patch as an urgency patch for users who are really bugged by the issue.

I have thought about it during the night and will try to submit something that takes in account the real meaning of WM_ENABLE.

WM_ENABLE is a change NOTIFICITATION of the appearance and WS_ACTIVE state of the windows control and the broadcasting of changing the children should occur somewhere before win32callbak does it.

kpp

2018-06-26 09:33

reporter   ~0109065

It solves my problems too, thank you

BrunoK

2018-06-28 16:21

reporter   ~0109116

Issue and patch documented in 0033923

BrunoK

2018-06-28 16:24

reporter   ~0109117

Last edited: 2018-06-28 16:25

View 2 revisions

And for kpp timings for his multi frame etc... examples with the patch in 33923

Second field : Now with milliseconds
Last field : obtained from RDTSC
Cost of sending a message to dbugintf, approx 0.120 milliseconds.

Timings for very slightly Simplified kpp's example W10testV2 tih all its frames
===============================================================================
Identify;14:59:51.522;Process W10Testbds
Information;14:59:51.522;-1; Application.Initialize; 85130645386430
Information;14:59:51.553;-1; 0; 8614EAC; S0 TApplication; 0; 0; 0; 85130748049443
Information;14:59:51.553;-1; 0; 8614EAC; S1 TApplication; 0; 0; 0; 85130748420773
Information;14:59:51.553;10000; Application.CreateForm; 85130754959883
Information;14:59:51.678;9999; TfmMainBds.Loaded; 85131227967900
Information;14:59:51.678;9998; TfmMainBds.FormCreate; 85131236821743
Information;14:59:51.959;9997; Application.Run; 85132247229418
Information;14:59:51.975;9996; TfmMainBds.FormShow; 85132311021951
Information;14:59:52.131;9995; Application.OnIdle; 85132895647050

kpp

2018-07-02 16:01

reporter   ~0109192

The patch 0033923 will cause problems in Lazarus.
If I have an exception, the buttons in the exception mask are no longer enabled.
I switch back to the simple patch (win32.patch) again.
Then everything works again.

BrunoK

2018-07-03 11:47

reporter   ~0109199

@kpp, yes you are right, I hadn't exactly understood what you meant.

Will review proposition.

kpp

2018-07-06 11:48

reporter   ~0109236

@BrunoK
Sorry, that I expressed myself in a misleading way.
It also appeared in the Fortes Report, if you wanted to print from the preview.
In the (probably) modal mask, all buttons were disabled.

Michl

2018-07-06 22:14

reporter   ~0109246

@BrunoK: Thank you for finding the problem! But I can't apply your patch, as it is a workaround to hide the problem.

Here https://msdn.microsoft.com/de-de/library/windows/desktop/ms646291(v=vs.85).aspx is written: By default, a window is enabled when it is created. To create a window that is initially disabled, an application can specify the WS_DISABLED style in the CreateWindow or CreateWindowEx function. After a window has been created, an application can use EnableWindow to enable or disable the window.

Maybe for a long time ago, there was WS_DISABLED used to create a window?! I don't know. After creating a window without this param, it isn't needed to enable it extra. I removed the line in Lazarus trunk revision 58448. It seems to work correct (tested on Win32: Windows XP, 7, 10, Linux Mint Cinnamon 18.3: GTK2, Qt, GTK3).

Please test and thanks for feedback!

Zeljan Rikalo

2018-07-22 10:35

reporter   ~0109621

Sorry, I've just opened an issue (related to this one) about Qt,Qt5 and Gtk2 (and other non win32 widgetsets). Changes from r58448 and r58407 are regression for all non win32 widgetsets.

Issue History

Date Modified Username Field Change
2018-05-07 13:41 kpp New Issue
2018-05-07 13:41 kpp File Added: W10Test.zip
2018-05-07 13:54 Pascal Riekenberg Note Added: 0108173
2018-05-07 21:44 Janusz Tomczak Note Added: 0108182
2018-05-07 23:25 wp Note Added: 0108186
2018-05-08 07:41 kpp File Added: W10testV2.zip
2018-05-08 07:43 kpp Note Added: 0108191
2018-05-12 06:11 Pascal Riekenberg Note Added: 0108243
2018-05-14 08:18 kpp Note Added: 0108277
2018-05-28 13:34 kpp Note Added: 0108558
2018-05-28 17:58 jamie philbrook Note Added: 0108561
2018-05-29 08:30 kpp Note Added: 0108569
2018-05-29 10:05 kpp Note Added: 0108572
2018-06-13 12:08 Pascal Riekenberg Note Added: 0108887
2018-06-25 17:00 BrunoK File Added: win32.patch
2018-06-25 17:00 BrunoK Note Added: 0109046
2018-06-25 20:26 Pascal Riekenberg Note Added: 0109047
2018-06-26 06:21 Pascal Riekenberg Note Edited: 0109047 View Revisions
2018-06-26 06:37 Pascal Riekenberg Note Added: 0109057
2018-06-26 09:07 BrunoK Note Added: 0109064
2018-06-26 09:33 kpp Note Added: 0109065
2018-06-27 13:14 Michl Assigned To => Michl
2018-06-27 13:14 Michl Status new => assigned
2018-06-28 16:21 BrunoK Note Added: 0109116
2018-06-28 16:24 BrunoK Note Added: 0109117
2018-06-28 16:25 Bart Broersma Relationship added related to 0033923
2018-06-28 16:25 BrunoK Note Edited: 0109117 View Revisions
2018-07-02 16:01 kpp Note Added: 0109192
2018-07-03 11:47 BrunoK Note Added: 0109199
2018-07-06 11:48 kpp Note Added: 0109236
2018-07-06 22:14 Michl Fixed in Revision => 58448
2018-07-06 22:14 Michl LazTarget => 1.10
2018-07-06 22:14 Michl Note Added: 0109246
2018-07-06 22:14 Michl Status assigned => resolved
2018-07-06 22:14 Michl Resolution open => fixed
2018-07-06 22:15 Michl Relationship replaced has duplicate 0033923
2018-07-22 10:33 Zeljan Rikalo Relationship added related to 0034018
2018-07-22 10:35 Zeljan Rikalo Note Added: 0109621