Skip to content

Cover Finder #216

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

Merged
merged 22 commits into from
Nov 18, 2022
Merged

Conversation

mariotaku
Copy link
Contributor

Description

This PR adds functionality to search game cover image, collected from IGDB.com.

Screenshot

image

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the docstring/documentation-blocks for new or existing methods/components

@github-actions github-actions bot changed the base branch from master to nightly June 19, 2022 15:34
@github-actions
Copy link

Your PR was set to master, PRs should be sent to nightly
The base branch of this PR has been automatically changed to nightly, please check that there are no merge conflicts

Copy link
Member

@TheElixZammuto TheElixZammuto left a comment

Choose a reason for hiding this comment

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

Unfortunately I'm not able to test this yet, but I have a couple feedback while skimming the code

key escape
url host check
@mariotaku mariotaku marked this pull request as ready for review June 27, 2022 16:22
@ReenigneArcher

This comment was marked as resolved.

@ReenigneArcher

This comment was marked as resolved.

@ReenigneArcher

This comment was marked as resolved.

@mariotaku

This comment was marked as resolved.

@ReenigneArcher

This comment was marked as resolved.

@ReenigneArcher

This comment was marked as resolved.

@mariotaku

This comment was marked as resolved.

@ReenigneArcher

This comment was marked as resolved.

@mariotaku

This comment was marked as resolved.

@mariotaku

This comment was marked as resolved.

@mariotaku mariotaku force-pushed the feature/cover-finder branch from ca59205 to 78407a4 Compare July 5, 2022 15:16
@mariotaku mariotaku requested a review from ReenigneArcher July 5, 2022 15:16
@ReenigneArcher

This comment was marked as resolved.

@mariotaku mariotaku force-pushed the feature/cover-finder branch from 08a8319 to 3489bd4 Compare August 24, 2022 13:43
@ReenigneArcher

This comment was marked as resolved.

@mariotaku

This comment was marked as resolved.

@ReenigneArcher
Copy link
Member

Hi. Sorry I've gotten busy these days. Is it possible to ask you to make some changes if you have clues to fix the above issues?

I will see what I can do, as well as check with some other developers.

These are some references for the missing dll issue.

It appears that we need to place the dll next to sunshine.exe or statically linking curl.

@ReenigneArcher ReenigneArcher added the help wanted Extra attention is needed label Oct 30, 2022
@psyke83
Copy link
Contributor

psyke83 commented Nov 17, 2022

Hi,

It seems there was a problem with static linking that affected libcurl.
If you cherry-pick this commit, it should work ok: psyke83@92b90cd

With the above commit:

# ldd sunshine.exe
        ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ff87ecf0000)
        KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ff87db50000)
        KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ff87c3f0000)
        ADVAPI32.dll => /c/Windows/System32/ADVAPI32.dll (0x7ff87e250000)
        msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ff87da10000)
        sechost.dll => /c/Windows/System32/sechost.dll (0x7ff87dc70000)
        RPCRT4.dll => /c/Windows/System32/RPCRT4.dll (0x7ff87e050000)
        bcrypt.dll => /c/Windows/System32/bcrypt.dll (0x7ff87c6d0000)
        CRYPT32.dll => /c/Windows/System32/CRYPT32.dll (0x7ff87cbe0000)
        ucrtbase.dll => /c/Windows/System32/ucrtbase.dll (0x7ff87cae0000)
        ole32.dll => /c/Windows/System32/ole32.dll (0x7ff87de90000)
        d3d11.dll => /c/Windows/SYSTEM32/d3d11.dll (0x7ff878100000)
        D3DCOMPILER_47.dll => /c/Windows/SYSTEM32/D3DCOMPILER_47.dll (0x7ff878370000)
        combase.dll => /c/Windows/System32/combase.dll (0x7ff87e300000)
        dwmapi.dll => /c/Windows/SYSTEM32/dwmapi.dll (0x7ff87a0f0000)
        win32u.dll => /c/Windows/System32/win32u.dll (0x7ff87c910000)
        win32u.dll => /c/Windows/System32/win32u.dll (0x1cb6d9e0000)
        GDI32.dll => /c/Windows/System32/GDI32.dll (0x7ff87d1c0000)
        dxgi.dll => /c/Windows/SYSTEM32/dxgi.dll (0x7ff87acb0000)
        USER32.dll => /c/Windows/System32/USER32.dll (0x7ff87eb10000)
        gdi32full.dll => /c/Windows/System32/gdi32full.dll (0x7ff87c9d0000)
        IPHLPAPI.DLL => /c/Windows/SYSTEM32/IPHLPAPI.DLL (0x7ff87b7c0000)
        msvcp_win.dll => /c/Windows/System32/msvcp_win.dll (0x7ff87c7c0000)
        CRYPTSP.dll => /c/Windows/SYSTEM32/CRYPTSP.dll (0x7ff87bda0000)
        SETUPAPI.dll => /c/Windows/System32/SETUPAPI.dll (0x7ff87e660000)
        cfgmgr32.dll => /c/Windows/System32/cfgmgr32.dll (0x7ff87c770000)
        WLDAP32.dll => /c/Windows/System32/WLDAP32.dll (0x7ff87e1e0000)
        WINMM.dll => /c/Windows/SYSTEM32/WINMM.dll (0x7ff872930000)
        WS2_32.dll => /c/Windows/System32/WS2_32.dll (0x7ff87d9a0000)
        WSOCK32.dll => /c/Windows/SYSTEM32/WSOCK32.dll (0x7ff86dc00000)
        MSWSOCK.DLL => /c/Windows/SYSTEM32/MSWSOCK.DLL (0x7ff87bb40000)

I did a quick test and the cover finder feature seems to retrieve images correctly on Windows 10.

@mariotaku
Copy link
Contributor Author

@psyke83 Very awesome change!

@ReenigneArcher
Copy link
Member

@psyke83 Thank you so much!

@mariotaku looks like a couple of failures, should be easy to resolve.

  1. clang reports an extra space
  2. docker build failing... missing a dependency per https://github.com/LizardByte/Sunshine/actions/runs/3488506314/jobs/5837582884#step:9:3163
#15 1.895 CMake Error at /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:603 (message):
#15 1.895   A required package was not found

Should just be a matter of adding the dependency here: https://github.com/mariotaku/Sunshine/blob/6806ae2335565f61b1629502d23ceed3eb2c004f/Dockerfile#L17

libcurl4-openssl-dev if I'm not mistaken.

@ReenigneArcher
Copy link
Member

ReenigneArcher commented Nov 17, 2022

#0 4.498 Reading package lists...
#0 5.230 Building dependency tree...
#0 5.357 Reading state information...
#0 5.362 Package libcurl4-openssl-dev is not available, but is referred to by another package.
#0 5.362 This may mean that the package is missing, has been obsoleted, or
#0 5.362 is only available from another source
#0 5.362 However the following packages replace it:
#0 5.363   libcurl4-doc
#0 5.363 
#0 5.365 E: Version '7.68.0*' for 'libcurl4-openssl-dev' was not found

Perhaps this is just a version issue. https://packages.ubuntu.com/jammy/libcurl4-openssl-dev

Flatpak failure is likely just an intermittent failure. It happens from time to time.

@mariotaku
Copy link
Contributor Author

@ReenigneArcher Oh! I thought 22.04 is focal.

@ReenigneArcher
Copy link
Member

Thanks for working on this everyone! I will test it in Windows 11 and 10 tonight. If it's all working, I'll assume we're good to merge, since it worked in Linux before.

@ReenigneArcher
Copy link
Member

ReenigneArcher commented Nov 18, 2022

Unfortunately, with Windows 11 I am still not able to upload the cover.

image

I can at least start Sunshine in Windows 10 now though. I couldn't get any further than that since my test machine doesn't have a display connected. I can test Windows 10 further tomorrow.

@psyke83
Copy link
Contributor

psyke83 commented Nov 18, 2022

I saw this on Sunshine's log output:

[2022:11:18:01:51:29]: Error: Couldn't download [https://images.igdb.com/igdb/image/upload/t_cover_big_2x/co4rjc.png, code:77]

Code 77 is related to the certificate store; presumably curl is not able to find it in the expected format on a Windows system. I feel that instead of copying the certificate store, it would be better to use Windows' own internal store instead.

To that effect, changing the build system to install mingw-w64-x86_64-curl-winssl (instead of mingw-w64-x86_64-curl, as they are in conflict), it seems that it will work. I might have had the -winssl variant installed when I tested, which is why I didn't catch the problem.

@psyke83
Copy link
Contributor

psyke83 commented Nov 18, 2022

Just to add some more context:

The winssl library seems to be included on Windows 10 or later only, so older versions may not work. Another alternative is to configure OpenSSL to use the Windows native store during compile time; see: https://curl.se/libcurl/c/CURLOPT_SSL_OPTIONS.html with the CURLSSLOPT_NATIVE_CA bitmask.

That might be worth investigating, but I'm not sure if it's worth the trouble? Windows 8.1 will be EOL in January 2023, and you'd have to be crazy to run Windows 7 in a networked environment.

@ReenigneArcher
Copy link
Member

The winssl library seems to be included on Windows 10 or later only, so older versions may not work.

Probably fine since Sunshine won't work in Windows 7 anyway. I've also yet to see a user report an issue and indicate they are using Windows 8.

@psyke83
Copy link
Contributor

psyke83 commented Nov 18, 2022

Well, either way seems to work on my system. Here's the OpenSSL workaround:

diff --git a/src/httpcommon.cpp b/src/httpcommon.cpp
index 092c2dc..e4747e3 100644
--- a/src/httpcommon.cpp
+++ b/src/httpcommon.cpp
@@ -197,6 +197,9 @@ bool download_file(const std::string &url, const std::string &file) {
   curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
   curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
   curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
+#ifdef _WIN32
+  curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA);
+#endif
   CURLcode result = curl_easy_perform(curl);
   if(result != CURLE_OK) {
     BOOST_LOG(error) << "Couldn't download ["sv << url << ", code:" << result << ']';

Edit: given that Sunshine already uses OpenSSL for crypto functions elsewhere in the code, it might make better sense to use the above workaround, as it may technically keep memory/library bloat to a minimum.

@ReenigneArcher
Copy link
Member

The workaround you provided seems logical to me. Let's go with that direction.

@mariotaku
Copy link
Contributor Author

I've applied @psyke83's patch. Really appreciate your suggestions!

@ReenigneArcher ReenigneArcher merged commit 01b8ba3 into LizardByte:nightly Nov 18, 2022
@psyke83 psyke83 mentioned this pull request Nov 18, 2022
12 tasks
@mariotaku mariotaku deleted the feature/cover-finder branch December 13, 2022 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants