Compare commits

8 Commits
Author SHA1 Message Date
Herrie 5904d54340 Merge pull request #1 from codepoet80/master
Viewport, Cache Clearing crash, build.sh clean-up
2026-08-24 06:03:49 +02:00
codepoet 59ede96a15 Merge branch 'Herrie82:master' into master 2026-08-23 16:49:46 -04:00
codepoet80andClaude Fable 5 273d1f7e05 Fix the 'GPU wedge' (atlas-wpe-env#3): three main-loop parks, none of them GPU
All three were reproduced and stack-traced live on-device (webOS CE 3.1.0);
A/B on the same hardware: stock engine wedged at page 8 of a cross-site
navigation loop and froze an animated page after ~1230 frames — fixed engine
cleared 64 pages and 1380+ frames with zero wedges.

1. Stale close of the WebKit-owned renderer-host fd (wpe-atlas-backend.c).
   view_get_renderer_host_fd() returned sock_web and closed it later, but
   PageClientImpl::hostFileDescriptor() ADOPTS the fd — WebKit ships it to
   the WebProcess and closes it within ms, so the number is reused (strace:
   by the very next socketpair, 80ms later) and the late close hit live fds.
   A wedged BS was captured recv()-blocked on an fd whose peer was a
   WPEWebProcess's WebKit IPC socket. Ownership now transfers at return;
   channels reap on HUP/EOF/NVAL; the main-loop recv is MSG_DONTWAIT.

2. Unread FRAME_ACK backlog (wpe-atlas-backend.c). The WebProcess never read
   the per-frame acks; unread unix datagrams stay charged to the SENDER's
   buffer, so the blocking ack send() parked the main loop after a few
   hundred frames on one page (caught in sock_alloc_send_pskb — the
   'wedged right after a good frame' signature). The WebProcess now drains
   acks before each FRAME_READY and all channel sends are non-blocking.

3. SIGUSR1 stolen from JSC (BrowserPageWPE.cpp). The scroll-test debug
   trigger's g_unix_signal_add(SIGUSR1) replaced WTF's thread-suspend
   handler; the UIProcess JSC collector hung in Thread::suspend ->
   sem_wait(globalSemaphoreForSuspendResume) and the main thread deadlocked
   in Heap::acquireAccessSlow (the classic futex wedge — caught by gdb after
   1+2 were fixed). Hook removed; the /tmp/atlas_scrolltest file trigger
   stays. If anything ever needs SIGUSR1, move JSC with JSC_SIGNAL_FOR_GC.

ARCHITECTURE.md rewritten accordingly. Pre-fix source rebuilds the shipped
0.9.10 binaries byte-identically, so the binary diff is exactly these fixes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmkRfybXhMBzbELMrKZWvp
2026-08-23 16:46:03 -04:00
codepoet80andClaude Opus 5 40cf1e4fbe docs: the GPU wedge is not in this backend's readback path
The hang in atlas-wpe-env#3 looks like it belongs to glFinish/eglLockSurfaceKHR
here, and the issue said so. On-device measurement says otherwise: BrowserServer's
main thread is in futex_wait_queue_me while the WPEWebProcess sits idle in poll,
killing the WebProcess does not free BS, and the last readback completed cleanly.
Record that here so the next person does not start debugging in this file.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 19:30:18 -04:00
codepoet80andClaude Opus 5 3a58c0b504 build.sh: work outside one developer's home directory
The script hardcoded /home/herrie/webos/wpe for both the toolchain environment and the source
directory, so it only ran in one person's checkout:

    WPE=/home/herrie/webos/wpe; . "${WPE_ENV:-$WPE/env-glibc-gcc125.sh}"
    cd "$WPE/backend-atlas"

Resolve the source directory from the script's own location, and honour a cross environment that is
already sourced (STAGING/CC/TARGET exported) before falling back to one next to this checkout.
WPE_ENV still overrides for other trees.

Also set the pkg-config search path the way cmake/atlas-arm-toolchain.cmake does. wpe-1.0, egl,
glesv2 and glib live in the staged webkitdeps tree in Debian multiarch layout, not in
$STAGING/lib/pkgconfig, so a plain cross environment fails to resolve any of them; without this the
build either stops or silently resolves against the host's /usr. Only applied when wpe-1.0 is not
already resolvable, so a caller with its own working setup is left alone.

Finally, make the frame-dump harness optional. It needs wpe-webkit-2.0 and libpng16 staged, and a
missing harness dependency should not fail the build of the backend itself, which is the deliverable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015tsY5bvFrBNb5e4pfYreJH
2026-07-25 12:14:06 -04:00
codepoet80andClaude Opus 5 8c444f2676 Implement clearAllCaches() for the WPE port
BrowserServer::clearCache() called QWebSettings::clearMemoryCaches(). QtWebKit
is headers-only in this port - there is no library behind it - so that call
linked to address 0 and SIGSEGV'd the engine outright.

It is not an obscure path. Preferences > Clear Cache reaches it through
serviceCmdClearCache, the adapter can reach it through asyncCmdClearCache, and
BrowserServer also calls it automatically when the device locale changes.

WPE 2.0 has no webkit_web_context_clear_cache(); cache clearing goes through the
network session's website-data manager. Clears memory + disk cache for every
live page.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015tsY5bvFrBNb5e4pfYreJH
2026-07-25 09:23:13 -04:00
codepoet80 34848ff8ad viewport work 2026-07-25 08:03:32 -04:00
codepoet80andClaude Opus 5 27d2a4defd patches: regenerate wma-wmv-canplaytype as a valid unified diff
The hunk header was a human note rather than line numbers:

    @@ ogg block closing brace, before "if (matroskaSupported)" @@

so patch(1) refused the file outright ("Only garbage was found in the patch
input") and the WMA/WMV canPlayType registration silently never made it into
any build done from this patch series. Regenerated against pristine
wpewebkit-2.52.4; the added code is byte-identical to what the note described.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015tsY5bvFrBNb5e4pfYreJH
2026-07-24 22:32:23 -04:00
6 changed files with 156 additions and 120 deletions

No files matched your search

+39
View File
@@ -78,6 +78,45 @@ fully offscreen (`EGL_KHR_surfaceless_context` + FBO, or a pbuffer). This decide
surfaceless/FBO is strongly preferred; if WebKit insists on a window surface we provide a 1x1
pbuffer-config window or the device fbdev native window and still read back via an FBO.
## The "GPU wedge" (atlas-wpe-env#3) — root cause, fixed 2026-08-23
The hang tracked as [atlas-wpe-env#3](https://github.com/Herrie82/atlas-wpe-env/issues/3) — after
GPU-heavy work (site menus, rotation, a few minutes of navigation) no page ever loads again, the
BrowserServer main thread sits in `futex_wait_queue_me` / `__skb_recv_datagram`, the WPEWebProcess is
idle — was never a GPU hang. It was three bugs on the UIProcess (BrowserServer) side — two in this file's
**frame channel**, one in BrowserPageWPE.cpp:
1. **Stale close of the fd handed to WebKit.** `view_get_renderer_host_fd()` returns one end of a
`socketpair`. WebKit wraps the return value `UnixFileDescriptor::Adopt` (`PageClientImpl::
hostFileDescriptor()`), ships it to the WebProcess and **closes it** — on another thread, within
milliseconds. The backend kept the number and closed it again when the first frame arrived. By then
the number had been reused (strace on-device: the very next `socketpair` got it back 80 ms later),
so that close hit a live fd — another channel's `sock_ui`, or a WebKit IPC socket. The channel's
`g_unix_fd_add` source then polled a foreign socket: a blocking `recv()` racing the IPC thread parks
the main loop in `__skb_recv_datagram`; a stolen IPC datagram leaves a sync reply that never comes
(`futex_wait_queue_me`); a closed IPC socket looks to WebKit like a crashed WebProcess, so it spawns
replacements while BS stays stuck. Fix: the returned end is WebKit's — never touched again; the
channel is reaped on HUP/EOF; `recv()` is `MSG_DONTWAIT`.
2. **Unread FRAME_ACK backlog.** The UIProcess answered every frame with an ack that the WebProcess
never read. Unread datagrams stay charged to the *sender's* socket buffer, so after a few hundred
frames on one page (an animated menu, a video, a long scroll session) the blocking `send(ack)`
parked the main loop forever — right after a perfectly good frame, which is exactly how the wedge
presented. Fix: the WebProcess drains acks before each FRAME_READY and the ack send is
`MSG_DONTWAIT`.
3. **SIGUSR1 stolen from JavaScriptCore** (`BrowserPageWPE.cpp`, not this file). A debug trigger for
the autonomous scroll test did `g_unix_signal_add(SIGUSR1, …)` once a page was live. WTF/JSC uses
SIGUSR1 (`sigThreadSuspendResume`) to suspend threads for conservative GC stack scanning, and glib's
`sigaction` replaced WTF's handler. The next concurrent GC of the UIProcess JSC VM (the one behind
`webkit_web_view_evaluate_javascript`'s JSCValues) then hung the collector in `Thread::suspend →
sem_wait(globalSemaphoreForSuspendResume)` waiting for a handler that no longer ran, and the main
thread's next heap entry parked in `JSC::Heap::acquireAccessSlow` — the `futex_wait_queue_me` wedge
caught on-device 2026-08-23 *after* fixes 1+2 were in. Fix: the SIGUSR1 hook is gone (the
`/tmp/atlas_scrolltest` file trigger remains). Nothing else in the engine may take SIGUSR1; if it ever
must, set `JSC_SIGNAL_FOR_GC=<signo>` in the boot wrapper instead.
None of this needs the watchdog that used to abort+respawn the engine; that watchdog is off (0.9.10).
## Build
`libWPEBackend-atlas.so`, linked against `libwpe-1.0`, `libEGL`/`libGLESv2` (stubs at build,
+50 -89
View File
@@ -22,7 +22,6 @@
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <sys/time.h>
#include <glib-unix.h> // g_unix_signal_add — SIGUSR1 kicks the autonomous scroll test
#include <sys/socket.h> // atlas-sensord Unix-socket client (DeviceOrientation/Motion)
#include <sys/un.h>
#include <cstring>
@@ -77,48 +76,6 @@ static int lunaConfInt(const char* key)
return val;
}
/* Low-memory device / forced viewport-only rendering. On a 512MB single-core phone (HP Pre 3) the
* multi-screen-tall pan buffer is too heavy, AND the STOCK Mojo browser UI can't send the per-card
* "atlas-simple:" marker. So the backend self-selects SIMPLE (viewport-only) rendering for EVERY page
* when it sees a low-RAM device or is explicitly told to. Evaluated once (cached).
* env BPWPE_FORCE_SIMPLE=1 -> force ON (set by the Pre 3 boot wrapper)
* env BPWPE_FORCE_SIMPLE=0 -> force OFF (escape hatch; wins over the RAM autodetect)
* /tmp/atlas_force_simple -> force ON at runtime (no wrapper restart)
* else -> ON if /proc/meminfo MemTotal <= ~640MB (catches 512MB devices)
* The TouchPad (~1GB MemTotal, no env/file) evaluates to false, so its behavior is unchanged. */
static bool bpwpe_force_low_mem()
{
static int cached = -1;
if (cached >= 0) return cached != 0;
const char* e = getenv("BPWPE_FORCE_SIMPLE");
if (e) { cached = (atoi(e) != 0) ? 1 : 0; return cached != 0; }
if (access("/tmp/atlas_force_simple", F_OK) == 0) { cached = 1; return true; }
long memTotalKb = 0;
FILE* mf = fopen("/proc/meminfo", "r");
if (mf) {
char line[128];
while (fgets(line, sizeof(line), mf))
if (sscanf(line, "MemTotal: %ld kB", &memTotalKb) == 1) break;
fclose(mf);
}
cached = (memTotalKb > 0 && memTotalKb <= 640000) ? 1 : 0; /* 512MB phones ~450-500MB MemTotal */
return cached != 0;
}
/* Reap the WebProcess on every top-level navigation (bound memory to one page instead of letting a
* long-lived card accumulate heap/cache across a session -> the pressure-thrash fix on 512MB). The cold
* WebProcess respawn is the cost. env BPWPE_REAP_ON_NAV=1 (Pre 3 device-profile) / =0 off / else falls
* back to the low-memory autodetect. Evaluated once. */
static bool bpwpe_reap_on_nav()
{
static int cached = -1;
if (cached >= 0) return cached != 0;
const char* e = getenv("BPWPE_REAP_ON_NAV");
if (e) { cached = (atoi(e) != 0) ? 1 : 0; return cached != 0; }
cached = bpwpe_force_low_mem() ? 1 : 0;
return cached != 0;
}
/* ---- Editor-focus → webOS VKB bridge (2.52 / 2.0 API). WPE has no QtWebKit microFocusChanged
* signal; the WebView instead drives a WebKitInputMethodContext when an editable element gains or
* loses focus. We subclass it, override notify_focus_in/out, and forward to the page, which raises
@@ -173,8 +130,7 @@ static inline bool bpwpe_dead(BrowserPageWPE* p) { return g_livePages.find(p) ==
struct ScrollTestState { bool active; int cy, dir, step, maxCy, steps, renders, uncovered; long maxStallMs; guint tick; };
static ScrollTestState g_st = {false,0,1,120,0,0,0,0,0,0};
static BrowserPageWPE* g_testablePage = nullptr; // last page to attach buffers = the scroll-test target
static gboolean on_sigusr1(gpointer); // fwd
static gboolean scrolltest_poll(gpointer); // fwd — file trigger (app-spawned BS masks SIGUSR1)
static gboolean scrolltest_poll(gpointer); // fwd — file trigger for the autonomous tests
BrowserPageWPE::BrowserPageWPE(BrowserServer* server, YapProxy* proxy)
: m_server(server), m_proxy(proxy), m_identifier(0)
@@ -822,10 +778,7 @@ void BrowserPageWPE::ensureWebView()
* on card close (both fixed), NOT the cache. WEB_BROWSER model keeps a real resource/bf cache (faster
* repeat loads + back/forward); WebKit's memory-pressure settings evict under load. DOCUMENT_VIEWER
* fallback via /tmp/atlas_nocache if memory regresses. */
/* Low-memory: use the DOCUMENT_VIEWER cache model (minimal resource cache, no dead-page retention)
* instead of WEB_BROWSER, so the WebProcess footprint stays small on 512MB — pairs with reap-on-nav
* and the bf-cache disable below. Overridable off the low-mem path via /tmp/atlas_nocache as before. */
bool s_cacheOn = (access("/tmp/atlas_nocache", F_OK) != 0) && !bpwpe_force_low_mem();
bool s_cacheOn = (access("/tmp/atlas_nocache", F_OK) != 0);
webkit_web_context_set_cache_model(ctx, s_cacheOn ? WEBKIT_CACHE_MODEL_WEB_BROWSER : WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
/* Render at the FULL device width. The adapter seeds m_virtualWindowWidth at ~960, which
@@ -841,13 +794,6 @@ void BrowserPageWPE::ensureWebView()
/* Screen dims from webOS config (luna.conf), falling back to the framebuffer — never hardcoded. */
int screenW = lunaConfInt("DisplayWidth");
int screenH = lunaConfInt("DisplayHeight");
/* Device screen-size override (HP Pre 3): webOS 2.2.4 reports the LEGACY-COMPAT logical panel size in
* luna.conf (DisplayWidth=320, DisplayHeight=480) even though the panel is physically 480x800 (it scales
* legacy apps 1.5x). Trusting luna.conf here makes the browser viewport square (480x480) — pages lay out
* in half the height and 100vh is wrong. The Pre 3 boot wrapper's device-profile sets BPWPE_SCREEN_W=480
* / BPWPE_SCREEN_H=800 so we render at the real panel size. No env on the TouchPad -> luna.conf wins. */
{ const char* ew = getenv("BPWPE_SCREEN_W"); if (ew && atoi(ew) > 0) screenW = atoi(ew);
const char* eh = getenv("BPWPE_SCREEN_H"); if (eh && atoi(eh) > 0) screenH = atoi(eh); }
if (screenW <= 0 || screenH <= 0) {
int fbfd = open("/dev/fb0", O_RDONLY);
if (fbfd >= 0) { struct fb_var_screeninfo vi;
@@ -947,6 +893,27 @@ void BrowserPageWPE::ensureWebView()
WLOG("ensureWebView layout %dx%d -> render %dx%d (screen=%d contentZoom=%.3f)",
renderW, renderH, m_renderWidth, m_renderHeight, screenW, (double)m_renderWidth/renderW);
/* VIEWPORT vs PAN BUFFER. renderH above is a PAINT extent (~4 screens) that the adapter pans
* within — it is not what the user can see. WebKit, left alone, uses the view height as the initial
* containing block, so a quirks-mode `height: 100%` layout (the classic centring table, e.g.
* home.jonandnic.com) resolves 100% to ~3072px and puts its "centred" content about a screen and a
* half below the fold. That is the "pages load halfway down" bug.
*
* Tell the WebProcess the real screen height so it can cap the ICB to one screen while still
* painting the whole buffer (WebCore/rendering/RenderView.cpp, atlasICBHeightCap()). Only meaningful
* when the buffer is actually taller than the screen; mult=1 needs no cap.
*
* setenv, not IPC: the WebProcess inherits our environment at spawn, and the engine runs
* WEBKIT_USE_SINGLE_WEB_PROCESS=1, so this is read once by the one process that matters. screenH
* comes from luna.conf DisplayHeight, which does not change on rotate (only the width does), so the
* value stays correct for the life of the process. */
if (screenH > 0 && renderH > screenH) {
char icb[16];
snprintf(icb, sizeof(icb), "%d", screenH);
setenv("ATLAS_ICB_HEIGHT", icb, 1);
WLOG("ICB height capped to screen: ATLAS_ICB_HEIGHT=%d (buffer %d)", screenH, renderH);
}
m_viewBackend = wpe_atlas_view_backend_create(renderW, renderH, scaledW, scaledH,
&BrowserPageWPE::onFrame, this);
WebKitWebViewBackend* vb = webkit_web_view_backend_new(m_viewBackend, nullptr, nullptr);
@@ -970,12 +937,15 @@ void BrowserPageWPE::ensureWebView()
}
/* This page has a live WebView -> it's the scroll-test target (NOT a startPage/tab that only
* attached buffers with screenH=0). Install the trigger once (poll works despite masked SIGUSR1). */
* attached buffers with screenH=0). Install the file-trigger poll once. NO SIGUSR1 hook here:
* WTF/JSC uses SIGUSR1 to suspend threads for conservative GC scanning, and g_unix_signal_add()
* replaced that handler — the collector then waited forever for the main thread to answer and the
* main thread deadlocked on the heap (JSC::Heap::acquireAccessSlow). That was one of the two
* "GPU wedge" (#3) mechanisms. */
g_testablePage = this;
static bool s_testInstalled = false;
if (!s_testInstalled) {
s_testInstalled = true;
g_unix_signal_add(SIGUSR1, on_sigusr1, nullptr);
g_timeout_add(700, scrolltest_poll, nullptr);
}
@@ -1012,9 +982,7 @@ void BrowserPageWPE::ensureWebView()
* A headless readout for on-device web-compat debugging (why site X rejects us / fails to load) with
* no inspector; off by default so production pays nothing. */
webkit_settings_set_enable_write_console_messages_to_stdout(s, access("/tmp/atlas_console", F_OK) == 0 ? TRUE : FALSE);
/* bf-cache = instant back/forward, but it retains prior pages in memory. Off in low-memory (keeps the
* WebProcess small on 512MB; back/forward reloads instead) or via /tmp/atlas_nocache. */
webkit_settings_set_enable_page_cache(s, (access("/tmp/atlas_nocache", F_OK) != 0 && !bpwpe_force_low_mem()) ? TRUE : FALSE);
webkit_settings_set_enable_page_cache(s, (access("/tmp/atlas_nocache", F_OK) != 0) ? TRUE : FALSE); /* bf-cache = instant back/forward; /dev/shm + leak fixes made the OOM moot. Disable via /tmp/atlas_nocache */
/* Runtime double-gating: these ship as build flags in the engine but WPE defaults them OFF, so the
* embedder must flip them on. EME uses WebKit's built-in ClearKey CDM (no external DRM needed).
* requestIdleCallback + LinkPrefetch are widely-used modern-web APIs defaulted off on WPE — enable via
@@ -1662,13 +1630,6 @@ void BrowserPageWPE::openUrl(const char* url)
WLOG("simple marker -> viewport mode (mult=1); target='%s'", u.c_str());
}
}
/* Low-memory device / forced simple: render EVERY page viewport-only even without the marker.
* This is what lets the unmodified stock Mojo browser (which never sends atlas-simple:) run on a
* 512MB Pre 3, and it belt-and-suspenders the Enyo app too. No-op on the TouchPad (see helper). */
if (!m_simpleMode && bpwpe_force_low_mem()) {
m_simpleMode = true;
WLOG("low-memory device/env -> forcing simple (viewport) mode");
}
/* A pre-warmed (about:blank, non-private) WebView can't serve a private card — tear it down so
* ensureWebView() rebuilds it ephemeral. Non-private navigations reuse the warm WebProcess.
* SAME for a SIMPLE card: the warm WebView was created with the default tall (mult=4) pan buffer
@@ -1680,16 +1641,6 @@ void BrowserPageWPE::openUrl(const char* url)
m_prewarmBlank = false;
if ((m_private || m_simpleMode) && m_webView) { g_object_unref(m_webView); m_webView = nullptr; }
}
/* REAP-ON-NAV (low memory): terminate the existing WebProcess before a new top-level load so the fresh
* page starts with a clean heap/cache instead of the card accumulating memory across the whole session.
* Only when a real WebView is still alive (prewarm teardown above may have cleared it) and we're loading
* a real page (not about:/data:). One cold WebProcess spawn is the cost; see bpwpe_reap_on_nav(). */
if (m_webView && bpwpe_reap_on_nav()
&& u.compare(0, 6, "about:") != 0 && u.compare(0, 5, "data:") != 0) {
WLOG("reap-on-nav: terminating previous WebProcess before loading '%s'", u.c_str());
webkit_web_view_terminate_web_process(m_webView);
g_object_unref(m_webView); m_webView = nullptr;
}
ensureWebView();
/* WebKit needs a scheme or it returns WebKitPolicyError 101 "URL can't be shown".
* The adapter passes the raw typed text (e.g. "cnn.com"), so add http:// if missing. */
@@ -2451,22 +2402,14 @@ void BrowserPageWPE::updateContentsSize()
-1, nullptr, nullptr, nullptr, &BrowserPageWPE::onContentHeight, this);
}
/* ===================== autonomous scroll test (SIGUSR1) ===================== */
/* ===================== autonomous scroll test (file trigger) ===================== */
static gboolean scrolltest_tick(gpointer)
{
if (!g_testablePage || g_livePages.find(g_testablePage) == g_livePages.end()) { g_st.active = false; return G_SOURCE_REMOVE; }
return g_testablePage->scrollTestStep() ? G_SOURCE_CONTINUE : G_SOURCE_REMOVE;
}
static gboolean on_sigusr1(gpointer)
{
if (g_testablePage && g_livePages.find(g_testablePage) != g_livePages.end() && !g_st.active)
g_testablePage->startScrollTest();
else
WLOG("SIGUSR1: no testable page (or a test is already running)");
return G_SOURCE_CONTINUE; /* keep the handler for repeated runs */
}
/* File trigger: the host `touch`es /tmp/atlas_scrolltest; polled on the glib loop (which is clearly
* dispatching — frames render), so it works even though the app-spawned BS has SIGUSR1 masked. */
/* File trigger: the host `touch`es /tmp/atlas_scrolltest; polled on the glib loop. (There used to be a
* SIGUSR1 trigger too — removed: SIGUSR1 belongs to JSC's GC thread-suspend, see ensureWebView.) */
static gboolean scrolltest_poll(gpointer)
{
if (access("/tmp/atlas_scrolltest", F_OK) == 0) {
@@ -2818,6 +2761,24 @@ static gboolean atlas_img_decide_dest(WebKitDownload* dl, gchar*, gpointer ud) {
webkit_download_set_destination(dl, static_cast<AtlasImgDl*>(ud)->dest.c_str()); return TRUE;
}
/* Clear the resource caches of every live page. Replaces QWebSettings::clearMemoryCaches(), which
* does not exist in this port (QtWebKit is headers-only here, so the call linked to address 0 and
* crashed). WPE 2.0 routes cache clearing through the network session's website-data manager. */
void BrowserPageWPE::clearAllCaches()
{
for (BrowserPageWPE* p : g_livePages) {
if (!p || !p->m_webView) continue;
WebKitNetworkSession* session = webkit_web_view_get_network_session(p->m_webView);
if (!session) continue;
WebKitWebsiteDataManager* mgr = webkit_network_session_get_website_data_manager(session);
if (!mgr) continue;
webkit_website_data_manager_clear(mgr,
static_cast<WebKitWebsiteDataTypes>(WEBKIT_WEBSITE_DATA_MEMORY_CACHE | WEBKIT_WEBSITE_DATA_DISK_CACHE),
0, nullptr, nullptr, nullptr);
}
WLOG("clearAllCaches: cleared memory+disk cache for %zu live page(s)", g_livePages.size());
}
void BrowserPageWPE::saveImageAtPointAsync(int32_t queryNum, int32_t x, int32_t y, const char* dir)
{
m_saveImgQuery = queryNum;
+5
View File
@@ -158,6 +158,11 @@ public:
* the image asynchronously and answer via m_server->msgHitTestResponse / msgSaveImageAtPointResponse. */
void hitTestAsync(int32_t queryNum, int32_t cx, int32_t cy);
void saveImageAtPointAsync(int32_t queryNum, int32_t x, int32_t y, const char* dir);
/* BrowserServer::clearCache() used QWebSettings::clearMemoryCaches(), a QtWebKit call with no
* library behind it in the WPE port - it linked to address 0 and SIGSEGV'd the engine. Reached
* from Preferences > Clear Cache, the asyncCmdClearCache IPC, AND automatically on a device
* locale change. Clears every live page's caches through the WPE 2.0 website-data manager. */
static void clearAllCaches();
void respondSaveImage(int32_t query, bool ok, const char* path); // Feature 9: called from the image-download callback
/* A payload starting with \x02 is an AUTOFILL request ("\x02" user "\x02" pass), routed through this
* existing command to avoid new IPC. Otherwise it's a plain InsertText into the focused field. */
+27 -2
View File
@@ -1,8 +1,27 @@
#!/bin/bash
# Cross-compile the Atlas WPE backend to libWPEBackend-atlas.so (musl/ARM softfp).
set -e
WPE=/home/herrie/webos/wpe; . "${WPE_ENV:-$WPE/env-glibc-gcc125.sh}"
cd "$WPE/backend-atlas"
# Toolchain env. Honour an already-sourced cross environment (STAGING/CC/TARGET exported); otherwise
# source one. WPE_ENV overrides; the default sits next to this checkout so the script works from any
# clone rather than only from the tree it was written in.
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
if [ -z "${STAGING:-}" ] || [ -z "${CC:-}" ]; then
ENV_SH="${WPE_ENV:-$SCRIPT_DIR/../atlas-wpe-env/env-atlas-cross.sh}"
[ -f "$ENV_SH" ] || { echo "build.sh: no cross env found at $ENV_SH - source it first or set WPE_ENV" >&2; exit 1; }
. "$ENV_SH"
fi
cd "$SCRIPT_DIR"
# pkg-config: wpe-1.0/egl/glesv2/glib live in the staged webkitdeps tree (Debian multiarch layout),
# not in $STAGING/lib/pkgconfig, so the plain cross env does not resolve them. Mirror what
# cmake/atlas-arm-toolchain.cmake sets so this builds against exactly what WebKit built against -
# and never against the host's /usr.
if ! pkg-config --exists wpe-1.0 2>/dev/null; then
WKDEPS="${ATLAS_WEBKITDEPS:-$STAGING/webkitdeps}"
export PKG_CONFIG_SYSROOT_DIR="$WKDEPS"
export PKG_CONFIG_LIBDIR="$WKDEPS/usr/lib/arm-linux-gnueabihf/pkgconfig:$WKDEPS/usr/share/pkgconfig:$STAGING/lib/pkgconfig"
unset PKG_CONFIG_PATH
fi
PKGS="wpe-1.0 glib-2.0 egl glesv2"
CF=$(pkg-config --cflags $PKGS)
LF=$(pkg-config --libs $PKGS)
@@ -17,6 +36,12 @@ echo " exports _wpe_loader_interface: $($TARGET-nm -D libWPEBackend-atlas.so |
echo " NEEDED: $($TARGET-readelf -d libWPEBackend-atlas.so | grep -oE '\[lib[^]]+\]' | tr '\n' ' ')"
echo "=== building frame-dump test harness ==="
# Optional: needs wpe-webkit-2.0 + libpng16 staged. The backend itself is the deliverable, so a
# missing harness dependency must not fail the build.
if ! pkg-config --exists wpe-webkit-2.0 libpng16 2>/dev/null; then
echo " skipped (wpe-webkit-2.0/libpng16 not in PKG_CONFIG_LIBDIR)"
exit 0
fi
HCF=$(pkg-config --cflags wpe-webkit-2.0 wpe-1.0 glib-2.0 libpng16)
HLF=$(pkg-config --libs wpe-webkit-2.0 glib-2.0 libpng16)
$CC $CFLAGS -std=gnu11 -Wall $HCF \
@@ -1,9 +1,6 @@
--- a/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp
@@ ogg block closing brace, before "if (matroskaSupported)" @@
if (auto result = factories.hasElementForMediaType(ElementFactories::Type::VideoDecoder, "video/x-theora"_s)) {
m_decoderMimeTypeSet.add("video/ogg"_s);
m_decoderCodecMap.add("theora"_s, result);
@@ -687,6 +687,24 @@
}
}
@@ -26,3 +23,5 @@
+ }
+
if (matroskaSupported) {
m_decoderMimeTypeSet.add("video/x-matroska"_s);
+32 -25
View File
@@ -104,7 +104,7 @@ static struct atlas_view* g_atlas_views = NULL; /* P2 wpe->view registry (few
* (which stalled loads with "bad SETUP" after a cross-site jump). Lives until its process exits. */
struct atlas_conn {
struct atlas_view* v;
int sock_ui, sock_web;
int sock_ui; /* our end. The peer end is handed to WebKit in view_get_renderer_host_fd and is not ours */
guint io_source;
};
@@ -192,46 +192,49 @@ static int view_get_renderer_host_fd(void* data)
}
struct atlas_conn* c = (struct atlas_conn*)calloc(1, sizeof(*c));
if (!c) { close(sv[0]); close(sv[1]); return -1; }
c->v = v; c->sock_ui = sv[0]; c->sock_web = sv[1];
c->v = v; c->sock_ui = sv[0];
/* tell THIS WebProcess where the shared frame buffer is (+ the fit-to-screen output size) */
struct atlas_msg m = { .type = MSG_SETUP, .shmid = (uint32_t)v->shmid,
.width = v->width, .height = v->height, .slot = 0,
.swidth = v->swidth, .sheight = v->sheight };
if (send(c->sock_ui, &m, sizeof(m), 0) != (ssize_t)sizeof(m))
if (send(c->sock_ui, &m, sizeof(m), MSG_NOSIGNAL) != (ssize_t)sizeof(m))
ATLAS_LOG("send(SETUP) failed: %s", strerror(errno));
/* receive THIS process's MSG_FRAME_READY on the UIProcess main loop */
c->io_source = g_unix_fd_add(c->sock_ui, G_IO_IN | G_IO_HUP | G_IO_ERR, atlas_view_on_readable, c);
c->io_source = g_unix_fd_add(c->sock_ui, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, atlas_view_on_readable, c);
/* Keep OUR sock_web open for now — WebKit dup()s the returned fd for the WebProcess
* (asynchronously), so closing it here would hand the process a dead fd (kills even the 1st
* load). It's dropped in atlas_view_on_readable on the process's FIRST message (which proves the
* dup already happened), so the socketpair can then HUP on process exit and reap the conn. */
return c->sock_web;
/* sv[1] now belongs to WebKit: PageClientImpl::hostFileDescriptor() ADOPTS it, sends it to the
* WebProcess and closes it (another thread, within ms). Closing it here later — as the old
* "close sock_web on first frame" did — closed whatever had since reused the number (another
* channel's sock_ui, a WebKit IPC socket): the main loop then parked in recv()/a lost IPC reply.
* That was the GPU "wedge" (atlas-wpe-env#3). The pair still HUPs when the WebProcess exits. */
return sv[1];
}
static gboolean atlas_view_on_readable(gint fd, GIOCondition cond, gpointer data)
{
struct atlas_conn* c = (struct atlas_conn*)data;
struct atlas_view* v = c->v;
if (cond & (G_IO_HUP | G_IO_ERR)) { /* this WebProcess exited — drop its channel */
if (c->sock_ui >= 0) close(c->sock_ui);
if (c->sock_web >= 0) close(c->sock_web);
if (cond & G_IO_NVAL) { free(c); return G_SOURCE_REMOVE; } /* fd already closed — not ours to close again */
/* Drain what is readable first (a HUP can arrive together with the last frame), never blocking
* the UI main loop; drop the channel on EOF/error, or on HUP/ERR once nothing is left to read. */
struct atlas_msg m;
ssize_t n = recv(fd, &m, sizeof(m), MSG_DONTWAIT);
if (n < 0 && (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)) {
if (!(cond & (G_IO_HUP | G_IO_ERR))) return G_SOURCE_CONTINUE;
n = 0; /* HUP with the queue drained: treat as EOF */
}
if (n <= 0) { /* this WebProcess exited (or the fd is bad) */
int e = n < 0 ? errno : 0;
if (e) ATLAS_LOG("frame channel fd %d: %s — dropping channel", fd, strerror(e));
if (e != EBADF) close(c->sock_ui);
free(c);
return G_SOURCE_REMOVE;
}
struct atlas_msg m;
ssize_t n = recv(fd, &m, sizeof(m), 0);
if (n != (ssize_t)sizeof(m)) return G_SOURCE_CONTINUE;
/* First real message proves WebKit already dup'd sock_web into the WebProcess, so drop OUR ref
* to it now (race-free: the process has its own copy). Without this the kept-open sock_web pins
* the socketpair so it never HUPs -> the conn (FD + io_source) leaks on every cross-site PSON
* spawn; this lets the pair HUP when the process exits, reaping the channel. */
if (c->sock_web >= 0) { close(c->sock_web); c->sock_web = -1; }
if (m.type == MSG_FRAME_READY && v->shm && v->handler) {
uint32_t slot = m.slot % SLOTS;
/* Slot addressing uses the LAYOUT size (allocation granularity); the frame's ACTUAL size
@@ -244,7 +247,7 @@ static gboolean atlas_view_on_readable(gint fd, GIOCondition cond, gpointer data
wpe_view_backend_dispatch_frame_displayed(v->wpe);
struct atlas_msg ack = { .type = MSG_FRAME_ACK, 0, 0, 0, slot };
send(fd, &ack, sizeof(ack), 0);
send(fd, &ack, sizeof(ack), MSG_DONTWAIT | MSG_NOSIGNAL);
}
return G_SOURCE_CONTINUE;
}
@@ -459,6 +462,7 @@ static void target_destroy(void* d)
{
struct atlas_target* t = (struct atlas_target*)d;
if (t->shm && t->shm != (void*)-1) shmdt(t->shm);
if (t->host_fd >= 0) close(t->host_fd); /* ours: WebKit passed hostFD.release() */
free(t->scratch);
free(t->ds_scratch);
free(t);
@@ -1283,12 +1287,15 @@ static void target_frame_rendered(void* d)
rw, rh, _rb, _iv, _iv ? 1000000.0 / _iv : 0.0, s_bgra_readback);
} _pn++; }
_plast = _pt1;
/* Drain the UIProcess's FRAME_ACKs. Nobody waits on them, but unread datagrams stay charged
* to the SENDER's buffer, so left alone they fill it after a few hundred frames and the
* BrowserServer's ack send() would block its main loop forever (the "wedge after a good frame"). */
{ struct atlas_msg a; while (recv(t->host_fd, &a, sizeof(a), MSG_DONTWAIT) > 0) {} }
struct atlas_msg m = { .type = MSG_FRAME_READY, .width = rw, .height = rh, .slot = t->cur_slot };
send(t->host_fd, &m, sizeof(m), 0);
send(t->host_fd, &m, sizeof(m), MSG_NOSIGNAL);
t->cur_slot = (t->cur_slot + 1) % SLOTS;
}
/* let WebKit proceed to the next frame (into the other slot). With double-buffering we don't
* wait for the UIProcess ack here; drain acks opportunistically for flow control if needed. */
/* let WebKit proceed to the next frame (into the other slot); we don't wait for the ack. */
wpe_renderer_backend_egl_target_dispatch_frame_complete(t->wpe);
}
static void target_deinitialize(void* d) { (void)d; }