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

Revert "ARRISEOS-45892 call GC on boot url" #404

Open
wants to merge 1 commit into
base: lgi-thunder4.2-20230922
Choose a base branch
from
Open
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
85 changes: 0 additions & 85 deletions WebKitBrowser/WebKitImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ WK_EXPORT void WKPreferencesSetPageCacheEnabled(WKPreferencesRef preferences, bo

#define URL_LOAD_RESULT_TIMEOUT_MS (15 * 1000)

#define GCCLEANER_PERIOD_SEC 4
#define GCCLEANER_CLEANUP_TIMES 4

namespace
{
static constexpr char ENV_WPE_CLIENT_CERTIFICATES_PATH[] = "/etc/ssl/private/";
Expand Down Expand Up @@ -976,78 +973,6 @@ static GSourceFuncs _handlerIntervention =
HangDetector& operator=(const HangDetector&) = delete;
};

class GCCleaner
{
WebKitImplementation& _browser;
GSource* _timerSource { nullptr };

std::atomic_int gc_executed_since_last_start;
public:

void start() {
if (_timerSource) {
TRACE(Trace::Information, (_T("GCCleaner already running; stop it first")));
stop();
}

_timerSource = g_timeout_source_new_seconds ( GCCLEANER_PERIOD_SEC );

g_source_set_callback (
_timerSource,
[](gpointer data) -> gboolean
{
if (static_cast<GCCleaner*>(data)->timerCallback()) {
return G_SOURCE_CONTINUE;
} else {
return G_SOURCE_REMOVE;
}
},
this,
nullptr
);
g_source_attach ( _timerSource, _browser._context );
}

void stop() {
if (_timerSource) {
g_source_destroy(_timerSource);
g_source_unref(_timerSource);
_timerSource = nullptr;
if (gc_executed_since_last_start.load() == 0) {
// we want to run at least once
TRACE(Trace::Information, (_T("GCCleaner: stopping without at least one invocation; execute GC now")));
webkit_web_context_garbage_collect_javascript_objects(webkit_web_view_get_context(_browser._view));
}
gc_executed_since_last_start.store(0);
}
}

bool timerCallback()
{
TRACE(Trace::Information, (_T("GCCleaner: running GC now")));
webkit_web_context_garbage_collect_javascript_objects(webkit_web_view_get_context(_browser._view));
++gc_executed_since_last_start;
return gc_executed_since_last_start.load() < GCCLEANER_CLEANUP_TIMES;
}

~GCCleaner()
{
if (_timerSource) {
g_source_destroy(_timerSource);
g_source_unref(_timerSource);
_timerSource = nullptr;
}
}

GCCleaner(WebKitImplementation& browser)
: _browser(browser), gc_executed_since_last_start(0)
{
}

GCCleaner(const HangDetector&) = delete;
GCCleaner& operator=(const HangDetector&) = delete;
};

private:
WebKitImplementation(const WebKitImplementation&) = delete;
WebKitImplementation& operator=(const WebKitImplementation&) = delete;
Expand Down Expand Up @@ -2651,11 +2576,6 @@ static GSourceFuncs _handlerIntervention =
if(!isCurrentUrlBootUrl && isNewUrlBootUrl && !_bootUrl.empty()) {
TRACE_L1("New URL: %s", URL.c_str());
ODH_WARNING("WPE0040", WPE_CONTEXT_WITH_URL(URL.c_str()), "New URL: %s", URL.c_str());
TRACE_L1("Starting GCCleaner");
gcCleaner->start();
} else {
TRACE_L1("Stopping GCCleaner");
gcCleaner->stop();
}

if (isNewUrlBlankUrl || (isCurrUrlMetroSubdomain && isNewUrlMetroSubdomain)) {
Expand Down Expand Up @@ -3544,7 +3464,6 @@ static GSourceFuncs _handlerIntervention =
#endif
}
#endif
std::unique_ptr<GCCleaner> gcCleaner;
uint32_t Worker() override
{
_context = g_main_context_new();
Expand All @@ -3553,8 +3472,6 @@ static GSourceFuncs _handlerIntervention =

HangDetector hangdetector(*this);

gcCleaner.reset(new GCCleaner{*this});

bool automationEnabled = _config.Automation.Value();

WebKitWebContext* wkContext;
Expand Down Expand Up @@ -3823,8 +3740,6 @@ static GSourceFuncs _handlerIntervention =

g_main_loop_run(_loop);

gcCleaner.reset(nullptr);

if (frameDisplayedCallbackID)
webkit_web_view_remove_frame_displayed_callback(_view, frameDisplayedCallbackID);
// webkit_user_content_manager_unregister_script_message_handler_in_world(userContentManager, "wpeNotifyWPEFramework", std::to_string(_guid).c_str());
Expand Down