Misc fixes beta.13

- Fixed some memory enhancement prefs not setting correctly.
- Bfcache is now completely disabled. This should improve memory, but kills Playwright's page.go_back() and page.go_forward(). To re-enable this, set `browser.sessionhistory.max_entries` to the amount of pages you want to remember.
- Moved SanitizeOnShutdown policy to preferences instead. This unlocks clearOnShutdown preferences. #47
- Added experimental memorysaver property that clears all of the memory after each page.goto navigation. Helpful for datacenters running Camoufox, but could potentially break things.
- Cursor now starts in a random position on the screen
- Fixed screenshots not capturing the full window when a viewport is set by window.innerWidth and window.innerHeight.
This commit is contained in:
daijro 2024-10-24 01:31:56 -05:00
parent 711b5b4550
commit dc3c0bde16
6 changed files with 481 additions and 447 deletions

View file

@ -383,7 +383,11 @@ class PageTarget {
this._tab = tab;
this._linkedBrowser = tab.linkedBrowser;
this._browserContext = browserContext;
this._viewportSize = undefined;
// Set the viewport size to Camoufox's default value.
this._viewportSize = {
width: ChromeUtils.camouGetInt("window.innerWidth") || 1280,
height: ChromeUtils.camouGetInt("window.innerHeight") || 720,
};;
this._initialDPPX = this._linkedBrowser.browsingContext.overrideDPPX;
this._url = 'about:blank';
this._openerId = opener ? opener.id() : undefined;
@ -570,14 +574,12 @@ class PageTarget {
// Otherwise, explicitly set page viewport prevales over browser context
// default viewport.
// Do not allow default viewport size if Camoufox set it first
// Camoufox is already handling viewport size, so we don't need to set it here.
if (
!this._viewportSize &&
this._browserContext.defaultViewportSize && (
ChromeUtils.camouGetInt("window.outerWidth") ||
ChromeUtils.camouGetInt("window.outerHeight") ||
ChromeUtils.camouGetInt("window.innerWidth") ||
ChromeUtils.camouGetInt("window.innerHeight"))
ChromeUtils.camouGetInt("window.outerWidth") ||
ChromeUtils.camouGetInt("window.outerHeight") ||
ChromeUtils.camouGetInt("window.innerWidth") ||
ChromeUtils.camouGetInt("window.innerHeight")
) {
return;
}

View file

@ -80,8 +80,17 @@ class PageHandler {
}
this._isDragging = false;
this._lastMousePosition = { x: 0, y: 0 };
this._lastTrackedPos = { x: 0, y: 0 };
// Camoufox: set a random default cursor position
let random_val = (max_val) => Math.floor(Math.random() * max_val);
// Try to fetch the viewport size
this._defaultCursorPos = {
x: random_val(this._pageTarget._viewportSize.width),
y: random_val(this._pageTarget._viewportSize.height),
};
this._lastMousePosition = { ...this._defaultCursorPos };
this._lastTrackedPos = { ...this._defaultCursorPos };
this._reportedFrameIds = new Set();
this._networkEventsForUnreportedFrameIds = new Map();
@ -423,6 +432,14 @@ class PageHandler {
});
unsubscribe();
if (ChromeUtils.camouGetBool('memorysaver', false)) {
ChromeUtils.camouDebug('Clearing all memory...');
Services.obs.notifyObservers(null, "child-gc-request");
Cu.forceGC();
Services.obs.notifyObservers(null, "child-cc-request");
Cu.forceCC();
}
return {
navigationId: sameDocumentNavigation ? null : navigationId,
};
@ -558,8 +575,8 @@ class PageHandler {
// NOTE: since this won't go inside the renderer, there's no need to wait for ACK.
win.windowUtils.sendMouseEvent(
'mousemove',
0 /* x */,
0 /* y */,
this._defaultCursorPos.x,
this._defaultCursorPos.y,
button,
clickCount,
modifiers,

File diff suppressed because it is too large Load diff

View file

@ -14,7 +14,6 @@
"DisableSetDesktopBackground": true,
"DisableDeveloperTools": false,
"NoDefaultBookmarks": true,
"SanitizeOnShutdown": true,
"DisableFirefoxScreenshots": true,
"DisableSafeMode": true,
"DisplayBookmarksToolbar": "never",

View file

@ -82,5 +82,6 @@
{ "property": "webGl2:shaderPrecisionFormats:blockIfNotDefined", "type": "bool" },
{ "property": "webGl:contextAttributes", "type": "dict" },
{ "property": "webGl2:contextAttributes", "type": "dict" },
{ "property": "memorysaver", "type": "bool" },
{ "property": "debug", "type": "bool" }
]

View file

@ -1,2 +1,2 @@
version=130.0.1
release=beta.12
release=beta.13