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

[RAPPS] Load icons on background thread #6881

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

whindsaks
Copy link
Contributor

@whindsaks whindsaks commented May 13, 2024

  • Load icons on a background thread to massively reduce loading time.

  • Use SM_CXICON sized icons consistently instead of hard-coding 32 in some places.

- Load icons on background thread to massively reduce loading time.

- Use SM_CXICON sized icons consistently instead of hardcoding 32 in some places.
@binarymaster binarymaster added the enhancement For PRs with an enhancement/new feature. label May 13, 2024
ItemCount = 0;
CheckedItemCount = 0;

ListView_Scroll(m_hWnd, 0, 0x7fff * -1); // Fixes a bug in Wine ComCtl32 where VScroll is not reset after deleting items
Copy link
Member

Choose a reason for hiding this comment

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

Is there a ticket for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not that I know of.

base/applications/rapps/appview.cpp Outdated Show resolved Hide resolved
}

VOID
CMainWindow::UpdateApplicationsList(AppsCategories EnumType, BOOL bReload, BOOL bCheckAvailable)
{
bUpdating = TRUE;

if (HCURSOR hCursor = LoadCursor(NULL, IDC_APPSTARTING))
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IDC_WAIT is the big hourglass and IDC_APPSTARTING is the arrow with small hourglass and is less jarring when the wait is somewhat short.

if (!AppInfo.RetrieveIcon(szIconPath))
return NULL;
SIZE_T cch = szIconPath.GetLength() + 1, cbstr = cch * sizeof(WCHAR);
CAsyncLoadIcon *task = (CAsyncLoadIcon*)LocalAlloc(LMEM_FIXED, sizeof(CAsyncLoadIcon) + cbstr);
Copy link
Contributor

Choose a reason for hiding this comment

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

why not using new operator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it would not let me use try/catch because of project settings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose I could use new std::nothrow.

base/applications/rapps/appview.cpp Outdated Show resolved Hide resolved
base/applications/rapps/appview.cpp Outdated Show resolved Hide resolved
static DWORD CALLBACK
AsyncLoadIconProc(LPVOID Param)
{
for (CAsyncLoadIcon *task = (CAsyncLoadIcon*)Param, *old; task; old->Free())
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this "old" variable ? Where is it defined?

Copy link
Contributor Author

@whindsaks whindsaks May 14, 2024

Choose a reason for hiding this comment

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

What do you mean, it's defined right there (and initialized and the end of the loop). It is walking the linked list and exists because you can't access the next pointer after freeing.

CopyMemory(task->Location, szIconPath.GetBuffer(), cbstr);
szIconPath.ReleaseBuffer();
task->pNext = g_AsyncIconTasks;
g_AsyncIconTasks = task;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this CAsyncLoadIcon::Queue() helper be called concurrently?
If so, this g_AsyncIconTasks should probably be InterlockedExchangePointer 'ed...
Or maybe, use a SLIST or something where queuing can be done atomically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It cannot, all of this is happening on the UI thread. And the assert is there to make sure it stays that way.

@HBelusca HBelusca self-requested a review May 14, 2024 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement For PRs with an enhancement/new feature.
Projects
None yet
5 participants