Browse Source

Weather: Fixed a bug that could prevent the widget from properly loading

It seems that either the web page, either something in Microsoft's
WebView2 implementation changed so that when
`ICoreWebView2::NavigationCompleted` is fired, the elements of interest
on the page are not ready, which causes all this mess, as you can tell.

The solution for now was to delay the execution of my scripts, which
seemed to have gotten rid of the problem for now. I don't particularly
like the solution, I'd of course want something more robust, but I
guess these are the pitfalls when you do not control the entire
ecosystem...
pull/1138/head
Valentin Radu 3 years ago
parent
commit
a8c7fbadaa
  1. 8
      ep_weather_host/ep_weather_host.c
  2. 2
      ep_weather_host/ep_weather_host.h

8
ep_weather_host/ep_weather_host.c

@ -572,7 +572,7 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_NavigationCompleted(GenericObjectWithThi @@ -572,7 +572,7 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_NavigationCompleted(GenericObjectWithThi
}
else
{
_epw_Weather_ExecuteDataScript(_this);
SetTimer(_this->hWnd, EP_WEATHER_TIMER_EXECUTEDATASCRIPT, EP_WEATHER_TIMER_EXECUTEDATASCRIPT_DELAY, NULL);
}
}
else
@ -1004,6 +1004,12 @@ LRESULT CALLBACK epw_Weather_WindowProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPA @@ -1004,6 +1004,12 @@ LRESULT CALLBACK epw_Weather_WindowProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPA
}
return 0;
}
else if (uMsg == WM_TIMER && wParam == EP_WEATHER_TIMER_EXECUTEDATASCRIPT)
{
_epw_Weather_ExecuteDataScript(_this);
KillTimer(_this->hWnd, EP_WEATHER_TIMER_EXECUTEDATASCRIPT);
return 0;
}
else if (uMsg == EP_WEATHER_WM_REBOUND_BROWSER)
{
LPWSTR uri = NULL;

2
ep_weather_host/ep_weather_host.h

@ -29,6 +29,8 @@ DEFINE_GUID(IID_ITaskbarList, @@ -29,6 +29,8 @@ DEFINE_GUID(IID_ITaskbarList,
#define EP_WEATHER_TIMER_SCHEDULE_REFRESH 11
#define EP_WEATHER_TIMER_RESIZE_WINDOW 15
#define EP_WEATHER_TIMER_RESIZE_WINDOW_DELAY 150
#define EP_WEATHER_TIMER_EXECUTEDATASCRIPT 20
#define EP_WEATHER_TIMER_EXECUTEDATASCRIPT_DELAY 500
typedef struct _GenericObjectWithThis GenericObjectWithThis;

Loading…
Cancel
Save