fix: improve web runtime resolution and restore x11vnc ncache
This commit is contained in:
+15
-1
@@ -57,6 +57,7 @@ PREWARM_POOL_SIZE = int(os.getenv("PREWARM_POOL_SIZE", "0"))
|
||||
UNIVERSAL_POOL_SIZE = int(os.getenv("UNIVERSAL_POOL_SIZE", "0"))
|
||||
WEB_POOL_SIZE = int(os.getenv("WEB_POOL_SIZE", "5"))
|
||||
WEB_POOL_BUFFER = int(os.getenv("WEB_POOL_BUFFER", "2"))
|
||||
X11VNC_FLAGS = os.getenv("X11VNC_FLAGS", "-wait 5 -defer 5 -ncache 10 -threads")
|
||||
MAX_ACTIVE_SERVICES_PER_USER = int(os.getenv("MAX_ACTIVE_SERVICES_PER_USER", "4"))
|
||||
WEB_RESOLUTION_MIN_WIDTH = int(os.getenv("WEB_RESOLUTION_MIN_WIDTH", "1024"))
|
||||
WEB_RESOLUTION_MIN_HEIGHT = int(os.getenv("WEB_RESOLUTION_MIN_HEIGHT", "720"))
|
||||
@@ -573,6 +574,7 @@ def ensure_universal_pool() -> None:
|
||||
"IDLE_TIMEOUT": str(SESSION_IDLE_SECONDS),
|
||||
"ENABLE_HEARTBEAT": "0",
|
||||
"SESSION_ID": f"universal-{i}",
|
||||
"X11VNC_FLAGS": X11VNC_FLAGS,
|
||||
}
|
||||
try:
|
||||
c = d.containers.get(name)
|
||||
@@ -634,6 +636,7 @@ def ensure_web_pool(target_size: Optional[int] = None) -> None:
|
||||
"IDLE_TIMEOUT": str(SESSION_IDLE_SECONDS),
|
||||
"ENABLE_HEARTBEAT": "0",
|
||||
"SESSION_ID": f"webpool-{i}",
|
||||
"X11VNC_FLAGS": X11VNC_FLAGS,
|
||||
}
|
||||
should_create = False
|
||||
try:
|
||||
@@ -869,6 +872,7 @@ def create_runtime_container(service: Service, session_id: str):
|
||||
"IDLE_TIMEOUT": str(SESSION_IDLE_SECONDS),
|
||||
"ENABLE_HEARTBEAT": "1",
|
||||
"TOUCH_PATH": f"/api/sessions/{session_id}/touch",
|
||||
"X11VNC_FLAGS": X11VNC_FLAGS,
|
||||
}
|
||||
image = "portal-kiosk:latest"
|
||||
|
||||
@@ -929,6 +933,7 @@ def ensure_warm_pool(service: Service, pool_size: Optional[int] = None) -> None:
|
||||
"IDLE_TIMEOUT": str(SESSION_IDLE_SECONDS),
|
||||
"ENABLE_HEARTBEAT": "0",
|
||||
"TOUCH_PATH": "",
|
||||
"X11VNC_FLAGS": X11VNC_FLAGS,
|
||||
}
|
||||
if service.type == ServiceType.WEB:
|
||||
base_env["UNIVERSAL_WEB"] = "1"
|
||||
@@ -1903,7 +1908,7 @@ def go_service(
|
||||
payload.update(extra)
|
||||
log_event("go_service_timing", **payload)
|
||||
|
||||
log_event("session_open_requested", user_id=user.id, service_slug=slug)
|
||||
log_event("session_open_requested", user_id=user.id, service_slug=slug, sw=sw, sh=sh)
|
||||
service = db.scalar(select(Service).where(Service.slug == slug, Service.active == True))
|
||||
if not service:
|
||||
raise HTTPException(status_code=404, detail="Service not found")
|
||||
@@ -1913,6 +1918,15 @@ def go_service(
|
||||
raise HTTPException(status_code=403, detail="ACL denied")
|
||||
|
||||
client_width, client_height = sanitize_client_resolution(sw, sh)
|
||||
log_event(
|
||||
"session_open_resolution",
|
||||
user_id=user.id,
|
||||
service_slug=slug,
|
||||
sw=sw,
|
||||
sh=sh,
|
||||
client_width=client_width,
|
||||
client_height=client_height,
|
||||
)
|
||||
|
||||
user_lock_started = time.perf_counter()
|
||||
try:
|
||||
|
||||
@@ -107,8 +107,27 @@
|
||||
}
|
||||
|
||||
function currentScreenParams() {
|
||||
const width = clamp(window.innerWidth || document.documentElement.clientWidth || 1280, 320, 7680);
|
||||
const height = clamp(window.innerHeight || document.documentElement.clientHeight || 720, 240, 4320);
|
||||
const screenWidth =
|
||||
window.screen && Number.isFinite(window.screen.width) && window.screen.width > 0
|
||||
? window.screen.width
|
||||
: null;
|
||||
const screenHeight =
|
||||
window.screen && Number.isFinite(window.screen.height) && window.screen.height > 0
|
||||
? window.screen.height
|
||||
: null;
|
||||
const viewportWidth =
|
||||
(window.visualViewport && window.visualViewport.width) ||
|
||||
window.innerWidth ||
|
||||
document.documentElement.clientWidth ||
|
||||
1280;
|
||||
const viewportHeight =
|
||||
(window.visualViewport && window.visualViewport.height) ||
|
||||
window.innerHeight ||
|
||||
document.documentElement.clientHeight ||
|
||||
720;
|
||||
// Prefer stable screen dimensions; viewport is fallback.
|
||||
const width = clamp(Math.round(screenWidth || viewportWidth), 320, 7680);
|
||||
const height = clamp(Math.round(screenHeight || viewportHeight), 240, 4320);
|
||||
const sp = new URLSearchParams();
|
||||
sp.set('sw', String(width));
|
||||
sp.set('sh', String(height));
|
||||
|
||||
Reference in New Issue
Block a user