WKE - High CPU usage
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);
}
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.
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.
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?