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

WKE - High CPU usage #596

Open
lexesv opened this issue Oct 14, 2024 · 3 comments
Open

WKE - High CPU usage #596

lexesv opened this issue Oct 14, 2024 · 3 comments

Comments

@lexesv
Copy link

lexesv commented Oct 14, 2024

Hello.

wke version 1.02
blink build 98096
build time Sat Aug 5 14:09:29 2023

CPU AMD Rizen 7 1700X

In headless mode, even after opening a web page (quite simple Json), the application continues to use the CPU at the level of 2.5-3%

How to solve this problem? Because your WKE browser from the examples does not consume as much CPU.

I provide an approximate code:

int main(int argc, char **argv) {

  char cCurrentPath[FILENAME_MAX];
  GetCurrentDir(cCurrentPath, sizeof(cCurrentPath));
  char dllpath[MAX_PATH];
  strcpy(dllpath, (const char *) cCurrentPath);
  strcat(dllpath, "\\node.dll");

  size_t cSize = strlen(dllpath) + 1;
  wchar_t *wdllpath = (wchar_t *) malloc(sizeof(wchar_t) * cSize);
  mbstowcs(wdllpath, dllpath, cSize);

  HMODULE hMod = LoadLibraryW(wdllpath);
  FN_wkeInitializeEx wkeInitializeExFunc = (FN_wkeInitializeEx) GetProcAddress(hMod, "wkeInitializeEx");
  wkeInitializeExFunc((wkeSettings *) 0);
    WKE_FOR_EACH_DEFINE_FUNCTION(WKE_GET_PTR_ITERATOR0, WKE_GET_PTR_ITERATOR1, WKE_GET_PTR_ITERATOR2,
                                 WKE_GET_PTR_ITERATOR3,
                                 WKE_GET_PTR_ITERATOR4, WKE_GET_PTR_ITERATOR5, WKE_GET_PTR_ITERATOR6,
                                 WKE_GET_PTR_ITERATOR11);
  free(wdllpath);

  // set proxy
  wkeSetProxy(&proxy)

  wkeWebView webView = wkeCreateWebView();
  wkeSetHeadlessEnabled(webView, true);

  wkeOnLoadUrlBegin(webView, LoadUrlBeginCallback, 0);
  wkeOnLoadUrlEnd(webView, LoadUrlEndCallback, 0);

  wkeSetUserAgent(webView, Task_ua);
  wkeSetLanguage(webView, "en-US");

  wkePostURL(webView, "https://httptest.pp.ua/post?=2562228&t=1728567681378", Task_postData, (size_t) strlen(Task_postData));

  wkeRunMessageLoop();
}

bool LoadUrlBeginCallback(wkeWebView webView, void *param, const utf8 *url, wkeNetJob job) {
    wkeNetHookRequest(job);
    wkeNetSetHTTPHeaderField(job, (const wchar_t *) L"accept", (const wchar_t *) L"application/json, text/javascript, /; q=0.01", false);
    wkeNetSetHTTPHeaderField(job, (const wchar_t *) L"x-requested-with", (const wchar_t *) L"XMLHttpRequest", false);
    return false;
}

void LoadUrlEndCallback(wkeWebView webView, void *param, const utf8 *url, wkeNetJob job, void *buf, int len) {
    printf("%s\n", buf);
}
@weolar
Copy link
Owner

weolar commented Oct 17, 2024

I'm in the process of upgrading the kernel and the performance will get a big boost then. I'll post a version next week that you can try.

@lexesv
Copy link
Author

lexesv commented Oct 17, 2024

I'm in the process of upgrading the kernel and the performance will get a big boost then. I'll post a version next week that you can try.

Thank you. I will wait.

@lexesv
Copy link
Author

lexesv commented Oct 31, 2024

I'm in the process of upgrading the kernel and the performance will get a big boost then. I'll post a version next week that you can try.

Hello.
Maybe the problem is not in the kernel? Maybe something wrong with the code?

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

No branches or pull requests

2 participants