New Window taking Many Times Longer in Windows than Mac to Open

I’m working on a project where the our main window takes 1.5 seconds to open on the Mac while on even on a relatively new Windows machine this can take 5 seconds (long enough for me to think the app might have frozen). There is no special Windows only code that accounts for the time difference. Is this just how less efficient Xojo Windows apps are?

FWIW, the window has a big container control that contains a page panel with about 18 additional containers.

I’ve tried a variety of things to help speed up the opening and I can’t get it to open faster in Windows to any significant degree. Does the Xojo hive mind has any ideas?

An idea for a workaround would be have a timer on the window with 1ms period to run 18 times and add each container to the page panel dynamically.
The short pause would allow the window to render earlier.

Otherwise it may be good to replicate the project to give Xojo Inc. something to time.
You could also log times in your project, e.g. in open event for each container and the whole window to get an idea where time is spend.

Yet another option is to have a nice, pretty splash screen set up as the App Default window. Have it launch a 5 second timer which would then Show the main window and close the splash screen.

This not the default screen. It’s really the document window. Presently that’s not an option.

Pretty sure you know my opinion on splash screens :stuck_out_tongue:
I like Christian’s embed dynamically idea, though it could get complicated fast.

I’m really curious if Profile Code has revealed anything that takes longer on Windows than Mac?

Nothing of note.

I wonder if the setup of a few controls takes much longer on Windows.
e.g. if a combobox has a 1000 lines initially and on Windows each time a row is added, the control redraws/recalculates.

or some loop taking O(n^2), which is no problem with 10 controls, but it noticed for 100.

I, too have noticed this on Windows vs. macOS apps with complex windows. I wonder if the xojo framework is adding control-by-control, and perhaps doing a window refresh at each step? That could certainly give an O(n**2) behavior as Christian surmises.

[quote]I wonder if the setup of a few controls takes much longer on Windows.
e.g. if a combobox has a 1000 lines initially and on Windows each time a row is added, the control redraws/recalculates.
[/quote]

I am sure this is true of a listbox.
I have code that turns off the scrollbars while filling for that reason.
And rather than refill a listbox, my code reuses existing rows.

I think that Xojo, differently of Microsoft, does a heavy use of timers for anything in the background and MS Timers sometimes sucks and usually have a lower resolution than Mac (If you say fire in 10 ms, it takes 35ms, if you say 1, it takes 35 too, NOT IN ALL MACHINES, some are 15). So in a heavy use of things in high resolution (like 1ms) it can take 34x more time to finish in some of those depending heavily on timers.

Swinging for the fence here, could you make the containers invisible on startup, then make them visible in a Timer after opening is complete?

Is there something like Instruments for Windows? Have you tried to use the built-in code profiler to see the differences in timings between macOS and Windows?

have you test the time with all transparence disabled?

Tried that initially. No difference.

All transparency is disabled as well as EraseBackground. I did that a month ago while looking at Windows-only drawing issues.

On Mac I can use the Instruments. I’ve not found anything like it for Windows. I have Profiled code but to be honest I trust the Windows readings much less than I do on the Mac. You find a method that takes a lot of time and then you drill down and the constituent method times don’t add up (not that they necessarily are going to but they don’t seem as accurate as the Mac side).

Then you can still the simple version of profiling where you do a

theErrorLog.LogItem(CurrentMethodName + " Open")

and the equivalent for the close to your start classes/windows/containers. It’s not nice but it works.

are threre any methods between that use the time?
could you measure this.
or take debug outputs time?
different time between debug & release mode?

When you refer to “Instruments” is that anything like XojoInstruments on github at kamehashi/XojoInstruments which does work on Windows? Or are you referring to a totally different tool?

@Dale Arends She has a number of blog posts about using Instruments on macOS https://www.mothsoftware.com/blog_page.php?permalink=chasing-the-beachball-with-instruments