Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gui/browserv7/inc/ROOT/RBrowser.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ public:
void AddTCanvas() { AddInitWidget("tcanvas"); }
void AddRCanvas() { AddInitWidget("rcanvas"); }

/// show Browser in specified place
void Show(const RWebDisplayArgs &args = "", bool always_start_new_browser = false);

/// hide Browser
void Hide();

void Sync();

std::string GetWindowUrl(bool remote);

void SetWorkingPath(const std::string &path);
Expand Down
11 changes: 10 additions & 1 deletion gui/browserv7/src/RBrowser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ RBrowser::RBrowser(bool use_rcanvas)
fWebWindow = RWebWindow::Create();
if (!fWebWindow)
return;

fWebWindow->SetDefaultPage("file:rootui5sys/browser/browser.html");

std::string sortby = gEnv->GetValue("WebGui.Browser.SortBy", "name"),
Expand Down Expand Up @@ -593,6 +593,15 @@ void RBrowser::Hide()
fWebWindow->CloseConnections();
}

///////////////////////////////////////////////////////////////////////////////////////////////////////
/// Run widget Sync method - processing pending actions

void RBrowser::Sync()
{
if (fWebWindow)
fWebWindow->Sync();
}

///////////////////////////////////////////////////////////////////////////////////////////////////////
/// Return URL parameter for the window showing ROOT Browser
/// See \ref ROOT::RWebWindow::GetUrl docu for more details
Expand Down
14 changes: 14 additions & 0 deletions gui/browserv7/src/RWebBrowserImp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@

using namespace ROOT;

class CleanupHandle {
RWebBrowserImp *fImp = nullptr;
public:

CleanupHandle(RWebBrowserImp *imp) { fImp = imp; }
~CleanupHandle() { printf("CleanupHandle destroyed\n"); }
};

////////////////////////////////////////////////////////////////////////////////////////
/// Default constructor

Expand All @@ -29,6 +37,8 @@ RWebBrowserImp::RWebBrowserImp(TBrowser *b) : TBrowserImp(b)

fWebBrowser = std::make_shared<RBrowser>();
fWebBrowser->AddTCanvas();

fWebBrowser->ClearOnClose(std::make_shared<CleanupHandle>(this));
}

////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -42,6 +52,8 @@ RWebBrowserImp::RWebBrowserImp(TBrowser *b, const char *title, UInt_t width, UIn
fHeight = height;
fWebBrowser = std::make_shared<RBrowser>();
fWebBrowser->AddTCanvas();

fWebBrowser->ClearOnClose(std::make_shared<CleanupHandle>(this));
}

////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -57,6 +69,8 @@ RWebBrowserImp::RWebBrowserImp(TBrowser *b, const char *title, Int_t x, Int_t y,
fHeight = height;
fWebBrowser = std::make_shared<RBrowser>();
fWebBrowser->AddTCanvas();

fWebBrowser->ClearOnClose(std::make_shared<CleanupHandle>(this));
}

////////////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions gui/webdisplay/inc/ROOT/RWebWindow.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private:
unsigned fConnId{0}; ///<! connection id (unique inside the window)
bool fHeadlessMode{false}; ///<! indicate if connection represent batch job
bool fWasFirst{false}; ///<! indicate if this was first connection, will be reinjected also on first place
bool fWasEstablished{false}; ///<! indicate if connection was established at least once
std::string fKey; ///<! key value supplied to the window (when exists)
int fKeyUsed{0}; ///<! key value used to verify connection
std::string fNewKey; ///<! new key if connection request reload
Expand Down
4 changes: 4 additions & 0 deletions gui/webdisplay/inc/ROOT/RWebWindowsManager.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private:
bool fUseHttpThrd{false}; ///<! use special thread for THttpServer
bool fUseSenderThreads{false}; ///<! use extra threads for sending data from RWebWindow to clients
float fLaunchTmout{30.}; ///<! timeout in seconds to start browser process, default 30s
float fReconnectTmout{15.}; ///<! timeout in seconds to reconnect connection, default 15s
bool fExternalProcessEvents{false}; ///<! indicate that there are external process events engine
std::unique_ptr<TExec> fAssgnExec; ///<! special exec to assign thread id via ProcessEvents
WebWindowShowCallback_t fShowCallback; ///<! function called for each RWebWindow::Show call
Expand All @@ -65,6 +66,9 @@ private:
/// Returns timeout for launching new browser process
float GetLaunchTmout() const { return fLaunchTmout; }

/// Returns timeout for launching new browser process
float GetReconnectTmout() const { return fReconnectTmout; }

void Unregister(RWebWindow &win);

/// Show window in specified location, see Show() method for more details
Expand Down
16 changes: 14 additions & 2 deletions gui/webdisplay/src/RWebWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -643,16 +643,21 @@ void RWebWindow::CheckPendingConnections()

timestamp_t stamp = std::chrono::system_clock::now();

float tmout = fMgr->GetLaunchTmout();
float launch_tmout = fMgr->GetLaunchTmout(),
reconnect_tmout = fMgr->GetReconnectTmout();

ConnectionsList_t selected;

bool do_clear_on_close = false;

{
std::lock_guard<std::mutex> grd(fConnMutex);

auto pred = [&](std::shared_ptr<WebConn> &e) {
std::chrono::duration<double> diff = stamp - e->fSendStamp;

float tmout = e->fWasEstablished ? reconnect_tmout : launch_tmout;

if (diff.count() > tmout) {
R__LOG_DEBUG(0, WebGUILog()) << "Remove pending connection " << e->fKey << " after " << diff.count() << " sec";
selected.emplace_back(e);
Expand All @@ -663,7 +668,12 @@ void RWebWindow::CheckPendingConnections()
};

fPendingConn.erase(std::remove_if(fPendingConn.begin(), fPendingConn.end(), pred), fPendingConn.end());

do_clear_on_close = (selected.size() > 0) && (fPendingConn.size() == 0) && (fConn.size() == 0);
}

if (do_clear_on_close)
fClearOnClose.reset();
}


Expand Down Expand Up @@ -855,6 +865,7 @@ bool RWebWindow::ProcessWS(THttpCallArg &arg)
if (conn) {
conn->fWSId = arg.GetWSId();
conn->fActive = true;
conn->fWasEstablished = true;
conn->fRecvSeq = 0;
conn->fSendSeq = 1;
// preserve key for longpoll or when with session key used for HMAC hash of messages
Expand Down Expand Up @@ -903,13 +914,14 @@ bool RWebWindow::ProcessWS(THttpCallArg &arg)

if (conn) {
bool do_clear_on_close = false;
if (!conn->fNewKey.empty()) {
if (!conn->fNewKey.empty() && (fMgr->GetReconnectTmout() > 0)) {
// case when same handle want to be reused by client with new key
std::lock_guard<std::mutex> grd(fConnMutex);
conn->fKeyUsed = 0;
conn->fKey = conn->fNewKey;
conn->fNewKey.clear();
conn->fConnId = ++fConnCnt; // change connection id to avoid confusion
conn->fWasEstablished = true;
conn->ResetData();
conn->ResetStamps(); // reset stamps, after timeout connection wll be removed
fPendingConn.emplace_back(conn);
Expand Down
2 changes: 2 additions & 0 deletions gui/webdisplay/src/RWebWindowsManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ bool RWebWindowsManager::CreateServer(bool with_http)
int fcgi_thrds = gEnv->GetValue("WebGui.FastCgiThreads", 10);
const char *fcgi_serv = gEnv->GetValue("WebGui.FastCgiServer", "");
fLaunchTmout = gEnv->GetValue("WebGui.LaunchTmout", 30.);
fReconnectTmout = gEnv->GetValue("WebGui.ReconnectTmout", 15.);
bool assign_loopback = gWebWinLoopbackMode;
const char *http_bind = gEnv->GetValue("WebGui.HttpBind", "");
bool use_secure = RWebWindowWSHandler::GetBoolEnv("WebGui.UseHttps", 0) == 1;
Expand Down Expand Up @@ -784,6 +785,7 @@ std::string RWebWindowsManager::GetUrl(RWebWindow &win, bool remote, std::string
/// WebGui.FirefoxProfilePath: file path to Firefox profile
/// WebGui.FirefoxRandomProfile: usage of random Firefox profile "no" - disabled, "yes" - enabled (default)
/// WebGui.LaunchTmout: time required to start process in seconds (default 30 s)
/// WebGui.ReconnectTmout: time to reconnect for already existing connection, if negative - no reconnecting possible (default 15 s)
/// WebGui.CefTimer: periodic time to run CEF event loop (default 10 ms)
/// WebGui.CefUseViews: "yes" - enable / "no" - disable usage of CEF views frameworks (default is platform/version dependent)
/// WebGui.OperationTmout: time required to perform WebWindow operation like execute command or update drawings
Expand Down
Loading