Compare commits

..
Author SHA1 Message Date
Hanif Koh d5165c3e75 Tell the Setup Wizard's Loading Page Only Once It Has Loaded
The wizard's loading page waits for HandleStudio to be called with
userguide_profile_load_finish and jumps to its target page on it; if the
call never arrives, a fallback timer in the page jumps after 180 s.

GuideFrame started the profile load from the first wxEVT_WEBVIEW_NAVIGATED
event and ran HandleStudio in the page as soon as the data was ready. That
event is the navigation's commit, before the page's scripts have run, and
with the wizard's derived cache the data is ready about 100 ms later.
Since the web view is created with an empty URL so the translated strings
can be injected before the first load, the first navigated event is the
commit of about:blank, so the data is ready before the real page has even
begun loading and the call reaches a page without HandleStudio. WebKit
drops the error and nothing retries, so on macOS the wizard often sits on
"Loading..." for three minutes before the printer list appears.

The loading page now reports in from its OnInit, the way the other wizard
pages request what they need, and the host sends the message once both
the data is ready and the page has reported; every instance of the page
reports again, so one that replaced an earlier one gets its own message.
2026-10-14 19:08:07 +08:00
3 changed files with 25 additions and 1 deletions
+5
View File
@@ -10,6 +10,11 @@ function OnInit()
// Orca: fallback timeout in case the C++ -> JS signal fails (e.g., WebKit issues).
// Jump to the target page after 3 minutes so slow computers don't get stuck on a partially loaded page.
setTimeout("JumpToTarget()",180*1000);
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="userguide_loading_page_ready";
SendWXMessage(JSON.stringify(tSend));
}
function HandleStudio( pVal )
+15 -1
View File
@@ -450,6 +450,16 @@ void GuideFrame::on_profile_loaded()
SaveProfileData();
const std::string strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished, json contents:\n" << strAll;
m_profile_ready = true;
notify_profile_loaded();
}
// The data is often ready before the loading page has run its scripts, and a
// call into a page without HandleStudio is lost, so the message waits for both.
void GuideFrame::notify_profile_loaded()
{
if (!m_profile_ready || !m_page_ready)
return;
json res;
res["command"] = "userguide_profile_load_finish";
res["sequence_id"] = "10001";
@@ -545,7 +555,11 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
wxString strCmd = j["command"];
BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;Command:" << strCmd;
if (strCmd == "close_page") {
if (strCmd == "userguide_loading_page_ready") {
m_page_ready = true;
notify_profile_loaded();
}
else if (strCmd == "close_page") {
this->EndModal(wxID_CANCEL);
}
if (strCmd == "user_clause") {
+5
View File
@@ -102,6 +102,7 @@ public:
int LoadProfileFamily(std::string strVendor, std::string strFilePath);
void init_guide_paths();
void on_profile_loaded();
void notify_profile_loaded();
bool BuildProfileJson(const PresetBundle& bundle, bool require_all_resource_vendors);
bool BuildProfileDataFromPresetBundle();
bool BuildProfileDataFromVendors();
@@ -142,6 +143,10 @@ private:
//First Load
bool bFirstComplete{false};
// The loading page gets userguide_profile_load_finish once both are true;
// every instance of it reports in, so the flag is never reset.
bool m_profile_ready{false};
bool m_page_ready{false};
// Set once in the destructor. Read through `this` by the loading thread
// (joined before `this` dies) and captured as the shared_ptr by CallAfter
// lambdas so they don't touch `this` after the object is freed.