Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display splash screen with win32 api on the first run so that Gtk can… #1263

Merged
merged 5 commits into from
Oct 15, 2021

Conversation

rados
Copy link
Contributor

@rados rados commented Aug 29, 2021

… load its font cache.

Please see related message in the discussion in issue #1207

@abitrolly
Copy link
Contributor

How does it actually look like?

@rados
Copy link
Contributor Author

rados commented Aug 30, 2021

How does it actually look like?

belachbit_windows_splash.mp4

@abitrolly
Copy link
Contributor

abitrolly commented Aug 30, 2021

Nice! I didn't expect the video, but now I know that it takes 45 seconds to load the fonts, which is a HUGE startup time.

The screen doesn't explain that font caching is only done one time after the installation.

If there is nothing right now to speed up fontconfig, then a link to some reference article explaining the problem would at least attract some people to tackle it. I started to collect some links, but nothing I can recommend as a solution.

Is there a way to get some progress values out of fontconfig? If there is not official API, then maybe monitoring the cache folder and comparing the amount of files there with amount of files in fonts could help to draw the progress bar.

@az0
Copy link
Member

az0 commented Sep 1, 2021

The window is spartan (not stylish), but it's functional. What other work might be needed for this?

Nice! I didn't expect the video, but now I know that it takes 45 seconds to load the fonts, which is a HUGE startup time.

It depends on quantity of fonts, hardware speed, etc. Without this, the user spends 45 seconds wondering what is going on.

@abitrolly
Copy link
Contributor

Without this, the user spends 45 seconds wondering what is going on.

Or just uninstalls the app.

@lgtm-com
Copy link

lgtm-com bot commented Sep 5, 2021

This pull request introduces 1 alert and fixes 1 when merging e15dfc6 into 5cb0cba - view on LGTM.com

new alerts:

  • 1 for Unused import

fixed alerts:

  • 1 for Wrong name for an argument in a call

@rados
Copy link
Contributor Author

rados commented Sep 5, 2021

I've found a way (with fc-scan.exe) to collect information about all fonts in a folder that contains which font for which languages could be used. So this may help us create a mapping between the system language and its corresponding fonts. The font info is like this:

Pattern has 23 elts (size 32)
family: "Tahoma"(s)
familylang: "en"(s)
style: "Normal"(s) "obyčejné"(s) "Standard"(s) "Κανονικά"(s) "Regular"(s) "Normaali"(s) "Normál"(s) "Normale"(s) "Standaard"(s) "Normalny"(s) "Обычный"(s) "Normálne"(s) "Navadno"(s) "thường"(s) "Arrunta"(s)
stylelang: "ca"(s) "cs"(s) "de"(s) "el"(s) "en"(s) "fi"(s) "hu"(s) "it"(s) "nl"(s) "pl"(s) "ru"(s) "sk"(s) "sl"(s) "vi"(s) "eu"(s)

@rados
Copy link
Contributor Author

rados commented Sep 5, 2021

The fix is still not perfect as the splash screen doesn't come on top on some systems.

@az0
Copy link
Member

az0 commented Sep 7, 2021

The fix is still not perfect as the splash screen doesn't come on top on some systems.

In this case, it is not worse than before.

If the startup crashes, could the splash screen thread be orphaned?

stylelang: "ca"(s) "cs"(s) "de"(s) "el"(s) "en"(s) "fi"(s) "hu"(s) "it"(s) "nl"(s) "pl"(s) "ru"(s) "sk"(s) "sl"(s) "vi"(s) "eu"(s)

Interesting. I compared it to the code pages listed on https://docs.microsoft.com/en-us/typography/font-list/tahoma . Here mentions Russian (ru), while the documentation mentions Cyrillic, so that makes sense. Both mention Vietnamese (vi/1258). The docs mention Turkish (1254), but fc-scan does not mention language code tr. Hmm. Still, this could be useful.

@@ -203,19 +203,6 @@ def environment_check():
NSIS_EXE, 'NSIS executable not found: will try to build portable BleachBit')


def remove_windir_from_fonts_conf():
filepath = 'dist\\etc\\fonts\\fonts.conf'
dom = xml.dom.minidom.parse(filepath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm warned that this change makes the import xml unneeded.

vcenter_rect = (0, rect[3] // 2 - 50, rect[2], rect[3])
win32gui.DrawText(
hDC,
("Welcome to Bleachbit, it is loading fonts.\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rados
This is informative text, but for now please let's go with simple instead like "BleachBit is starting".

If there could be a progress bar or spinner, I would make the text simpler, and many Android apps I tested use just a logo. Let's not worry about these for now, though.

return 0

elif message == win32con.WM_DESTROY:
print('Being destroyed')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is needed, please use logger

bleachbit/CLI.py Outdated
@@ -174,6 +174,7 @@ def process_cmd_line():
if 'nt' == os.name:
parser.add_option("--update-winapp2", action="store_true",
help=_("update winapp2.ini, if a new version is available"))
parser.add_option("--run-from-installer", action="store_true")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
parser.add_option("--run-from-installer", action="store_true")
parser.add_option("--run-from-installer", action="store_true", help=optparse.SUPPRESS_HELP)

@rados
Copy link
Contributor Author

rados commented Sep 7, 2021

Interesting. I compared it to the code pages listed on https://docs.microsoft.com/en-us/typography/font-list/tahoma . Here mentions Russian (ru), while the documentation mentions Cyrillic, so that makes sense. Both mention Vietnamese (vi/1258). The docs mention Turkish (1254), but fc-scan does not mention language code tr. Hmm. Still, this could be useful.

There is one more entry for family: 'Tahoma' that includes tr:

Pattern has 23 elts (size 32)
family: "Tahoma"(s)
familylang: "en"(s)
style: "Negreta"(s) "tučné"(s) "fed"(s) "Fett"(s) "Έντονα"(s) "Bold"(s) "Negrita"(s) "Lihavoitu"(s) "Gras"(s) "Félkövér"(s) "Grassetto"(s) "Vet"(s) "Halvfet"(s) "Pogrubiony"(s) "Negrito"(s) "Полужирный"(s) "Fet"(s) "Kalın"(s) "Krepko"(s) "đậm"(s) "Lodia"(s)
stylelang: "ca"(s) "cs"(s) "da"(s) "de"(s) "el"(s) "en"(s) "es"(s) "fi"(s) "fr"(s) "hu"(s) "it"(s) "nl"(s) "no"(s) "pl"(s) "pt"(s) "ru"(s) "sv"(s) "tr"(s) "sl"(s) "vi"(s) "eu"(s)
fullname: "Tahoma Negreta"(s) "Tahoma tučné"(s) "Tahoma fed"(s) "Tahoma Fett"(s) "Tahoma Έντονα"(s) "Tahoma Bold"(s) "Tahoma Negrita"(s) "Tahoma Lihavoitu"(s) "Tahoma Gras"(s) "Tahoma Félkövér"(s) "Tahoma Grassetto"(s) "Tahoma Vet"(s) "Tahoma Halvfet"(s) "Tahoma Pogrubiony"(s) "Tahoma Negrito"(s) "Tahoma Полужирный"(s) "Tahoma Fet"(s) "Tahoma Kalın"(s) "Tahoma Krepko"(s) "Tahoma đậm"(s) "Tahoma Lodia"(s)
fullnamelang: "ca"(s) "cs"(s) "da"(s) "de"(s) "el"(s) "en"(s) "es"(s) "fi"(s) "fr"(s) "hu"(s) "it"(s) "nl"(s) "no"(s) "pl"(s) "pt"(s) "ru"(s) "sv"(s) "tr"(s) "sl"(s) "vi"(s) "eu"(s)

@lgtm-com
Copy link

lgtm-com bot commented Sep 14, 2021

This pull request introduces 1 alert and fixes 1 when merging 3e029b6 into e5b5763 - view on LGTM.com

new alerts:

  • 1 for Unused import

fixed alerts:

  • 1 for Wrong name for an argument in a call

@rados
Copy link
Contributor Author

rados commented Sep 14, 2021

I've done the following tests to verify that the splash screen is always on top of all other windows (it was a challenge):

win 8 64 bit:
- run portable no privileges - ok
- run portable with privileges - ok
- install as admin and run no privileges - ok
- install as admin and run with privileges - ok
- install as local user and run no privileges - ok
- install as local user and run with privileges - ok

win server 2019 64 bit:
- install as admin and run with privileges - ok
- install as admin and run no privileges - ok

win 7 32 bit:
- install as admin and run no privileges - ok
- install as admin and run with privileges - ok

win 10 64 bit:
- install as admin and run no privileges - ok
- install as admin and run with privileges - ok
- install for all users with uac turned off - ok

@az0
Copy link
Member

az0 commented Sep 15, 2021

I've done the following tests to verify that the splash screen is always on top of all other windows (it was a challenge):

Thank you for working hard on this. Is this PR now ready for review and merge?

@rados
Copy link
Contributor Author

rados commented Sep 15, 2021

I've done the following tests to verify that the splash screen is always on top of all other windows (it was a challenge):

Thank you for working hard on this. Is this PR now ready for review and merge?

Only the look remains. This is my current work with icon:

image

@lgtm-com
Copy link

lgtm-com bot commented Sep 16, 2021

This pull request introduces 1 alert and fixes 1 when merging 955572b into e837e56 - view on LGTM.com

new alerts:

  • 1 for Unused import

fixed alerts:

  • 1 for Wrong name for an argument in a call

@az0
Copy link
Member

az0 commented Sep 24, 2021

Looks like an unrelated test is failing. It happened last week and today, and I don't get this error from the main branch. It makes it hard to test the PR because there is no build artifact on AppVeyor. I will look more into this later

ERROR: test_update_url (tests.TestUpdate.UpdateTestCase)
Check connection to the update URL
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\bleachbit\tests\TestUpdate.py", line 99, in test_update_url
    handle = opener.open(bleachbit.update_check_url)
  File "c:\python34\lib\urllib\request.py", line 470, in open
    response = meth(req, response)
  File "c:\python34\lib\urllib\request.py", line 580, in http_response
    'http', request, response, code, msg, hdrs)
  File "c:\python34\lib\urllib\request.py", line 508, in error
    return self._call_chain(*args)
  File "c:\python34\lib\urllib\request.py", line 442, in _call_chain
    result = func(*args)
  File "c:\python34\lib\urllib\request.py", line 588, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 406: Not Acceptable
----------------------------------------------------------------------
Ran 212 tests in 133.970s
FAILED (errors=1, skipped=34)

@az0
Copy link
Member

az0 commented Sep 24, 2021

I see a 406 return code on the update server coming from AppVeyor IP address (67.225.164.41) and user agent "Python-urllib/3.4"

@az0
Copy link
Member

az0 commented Oct 14, 2021

I fixed the HTTP 406 error and now it will be easier to review this PR

@az0
Copy link
Member

az0 commented Oct 15, 2021

Looks OK

I tested build 4.4.1.2119 on Windows 10 build 19042 (20H2).

First, I deleted fontconfig directory, installed it, ran as admin, and splash screen stayed up for 40 seconds. Then it proceeded normally.

Second, I started again as admin, and splash screen flickered and disappeared under one second.

Third, I repeated 1 and 2 as non-admin, and it worked the same except time was 25 seconds the first time to rebuild the cache.

@az0 az0 merged commit ae956a2 into bleachbit:master Oct 15, 2021
@m0lz
Copy link

m0lz commented Nov 11, 2021

@az0 I found something unusual with this ..

First I am testing 4.4.1 beta as described here https://www.bleachbit.org/news/bleachbit-441-beta

On windows 10 home, 21H1, OS build 19043.1348

Note well - All tests requested, Windows + Linux, and Windows Only tests, completed succesfully without issue except one thing unusual cropped up ...

During the following procedure
"In the Windows control panel, uninstall BleachBit. Delete the folder %localappdata%\fontconfig, if it exists. Install the new installer, and after it is done and before starting the application, verify the folder exists. Delete the folder and start the application. Verify there is a splash screen that appears while the folder is being created, which usually last roughly 20 to 60 seconds (issue 1263). Restart the application, and verify the startup is much faster because it used the font cache from the previous start."

Within the folder %localappdata%\fontconfig there is a cache folder which I am also deleting.

On first install of BleachBit-4.4.1-setup.exe (double click the downloaded installer, not run through the command line), and choosing "Install only for me", before we get to the splash screen there is a command line opens - See attached screenshot below - for fc-cache.exe

This command window opens for quite a long period (circa 5-10 seconds) before it closes and the rest of the installation goes ahead.

I mention it because it is an unusual and unexpected part of the installation process

Untitled

Would this ordinarily be silent, if so then it is probably a none issue and maybe due to me launching the beta installer via icon instead of command line, and having deleted the cache folder within fontconfig aswell as fontconfig.

As mentioned already though all other tests on the page linked at the start of this post went well for my setup.

Edit: Just one minor cosmetic thing though .. That splash screen, the Bleachbit Icon looks a bit odd being so close to the left edge of the splash.

az0 added a commit that referenced this pull request Nov 13, 2021
@az0
Copy link
Member

az0 commented Nov 13, 2021

On first install of BleachBit-4.4.1-setup.exe (double click the downloaded installer, not run through the command line), and choosing "Install only for me", before we get to the splash screen there is a command line opens - See attached screenshot below - for fc-cache.exe

This command window opens for quite a long period (circa 5-10 seconds) before it closes and the rest of the installation goes ahead.

I mention it because it is an unusual and unexpected part of the installation process

The command window that shows up during the installer is normal. It is building the font cache, so the first time the application starts is faster. I'll write a note in the release notes, and I added code to the installer to explain what is happening (718bdee).

By the way, the font cache building (command window) is not directly related to this pull request about the splash screen.

Edit: Just one minor cosmetic thing though .. That splash screen, the Bleachbit Icon looks a bit odd being so close to the left edge of the splash.
image

Yes, it could have a more aesthetic design. Let's come back to this in a future release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants