Skip to content

Commit

Permalink
Fix frame callback (#143)
Browse files Browse the repository at this point in the history
* Don't wait for first compositor action when
sending frame feedback + fix small errors

* Update deps

* Make wlsurface reusable for popups for gtk4

* remove log line

* undefined value fixes
  • Loading branch information
Zubnix authored Feb 21, 2024
1 parent 84d63cb commit 99dea7e
Show file tree
Hide file tree
Showing 29 changed files with 852 additions and 315 deletions.
2 changes: 1 addition & 1 deletion libs/client-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"packageManager": "[email protected]",
"dependencies": {
"camelcase": "^8.0.0",
"meow": "^12.1.1",
"meow": "^13.2.0",
"uppercamelcase": "^3.0.0",
"xml2js": "^0.6.2"
}
Expand Down
16 changes: 8 additions & 8 deletions libs/client-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
},
"devDependencies": {
"@gfld/client-generator": "workspace:^",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.3",
"rimraf": "^5.0.4",
"typescript": "^5.2.2"
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"typescript": "^5.3.3"
}
}
16 changes: 8 additions & 8 deletions libs/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
"build": "yarn run tsc"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.3",
"rimraf": "^5.0.4",
"typescript": "^5.2.2"
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"typescript": "^5.3.3"
}
}
16 changes: 8 additions & 8 deletions libs/compositor-ffmpeg-h264/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"build": "yarn run build-wasm && yarn run build-ts"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"acorn": "^8.10.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"acorn": "^8.11.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"typescript": "^5.3.3"
},
"author": "Erik De Rijcke",
"homepage": "https://github.com/udevbe/tinyh264",
Expand Down
2 changes: 1 addition & 1 deletion libs/compositor-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"packageManager": "[email protected]",
"dependencies": {
"camelcase": "^8.0.0",
"meow": "^12.1.1",
"meow": "^13.2.0",
"uppercamelcase": "^3.0.0",
"xml2js": "^0.6.2"
},
Expand Down
16 changes: 8 additions & 8 deletions libs/compositor-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
},
"devDependencies": {
"@gfld/compositor-generator": "workspace:^",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"mkdirp": "^3.0.1",
"prettier": "^3.0.3",
"rimraf": "^5.0.4",
"typescript": "^5.2.2"
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"typescript": "^5.3.3"
}
}
2 changes: 1 addition & 1 deletion libs/compositor-proxy-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"contributors": [],
"dependencies": {
"camelcase": "^8.0.0",
"meow": "^12.1.1",
"meow": "^13.2.0",
"uppercamelcase": "^3.0.0",
"xml2js": "^0.6.2"
},
Expand Down
16 changes: 8 additions & 8 deletions libs/compositor-wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"build": "./build_wasm.sh && yarn run tsc"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"acorn": "^8.10.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"acorn": "^8.11.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"typescript": "^5.3.3"
}
}
24 changes: 12 additions & 12 deletions libs/xtsb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@
"packageManager": "[email protected]",
"devDependencies": {
"@tsconfig/node18": "^18.2.2",
"@types/jest": "^29.5.5",
"@types/node": "^18.15.3",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"@types/jest": "^29.5.12",
"@types/node": "^18.19.17",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"jest-config": "^29.7.0",
"prettier": "^3.0.3",
"rimraf": "^5.0.4",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
}
30 changes: 15 additions & 15 deletions packages/compositor-proxy-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@
"dependencies": {
"@gfld/compositor-proxy": "workspace:^",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1"
"ajv-formats": "^2.1.1",
"ws": "^8.16.0"
},
"devDependencies": {
"@tsconfig/node18": "^18.2.2",
"@types/js-yaml": "^4.0.6",
"@types/jsonwebtoken": "^9.0.3",
"@types/node": "^18.18.7",
"@types/ws": "^8.5.6",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"@types/js-yaml": "^4.0.9",
"@types/jsonwebtoken": "^9.0.5",
"@types/node": "^18.19.17",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"json-schema-to-typescript": "^13.1.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"json-schema-to-typescript": "^13.1.2",
"mkdirp": "^3.0.1",
"pkg": "^5.8.1",
"prettier": "^3.0.3",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"ts-node": "^10.9.1",
"tsx": "^3.14.0",
"typescript": "^5.2.2"
"tsx": "^4.7.1",
"typescript": "^5.3.3"
},
"pkg": {
"scripts": [
Expand Down
21 changes: 18 additions & 3 deletions packages/compositor-proxy-cli/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Configschema, createLogger } from '@gfld/compositor-proxy'
import { createServer } from 'node:http'
import { createServer, IncomingMessage } from 'node:http'
import { ChildProcess, fork } from 'node:child_process'
import { ToSessionProcessMessage } from './SessionProcess.js'
import { Socket } from 'node:net'
import { authRequest, handleGET, handleOptions } from './main-controller.js'
import { args } from './main-args.js'
import { inspect } from 'node:util'
import path from 'node:path'
import { WebSocketServer } from 'ws'

process.on('uncaughtException', (e) => {
logger.error('\tname: ' + e.name + ' message: ' + e.message)
Expand Down Expand Up @@ -44,13 +45,27 @@ function main() {
const url = new URL(request.url ?? '', `http://${request.headers.host}`)
const compositorSessionId = url.searchParams.get('compositorSessionId')
if (compositorSessionId === null) {
socket.end()
new WebSocketServer({ perMessageDeflate: false, noServer: true }).handleUpgrade(
request as IncomingMessage,
socket,
Buffer.from([]),
(ws) => {
ws.close(4403)
},
)
return
}

const childProcess = sessionProcesses[compositorSessionId]
if (childProcess === undefined) {
socket.end()
new WebSocketServer({ perMessageDeflate: false, noServer: true }).handleUpgrade(
request as IncomingMessage,
socket,
Buffer.from([]),
(ws) => {
ws.close(4403)
},
)
return
}

Expand Down
6 changes: 2 additions & 4 deletions packages/compositor-proxy-cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"allowJs": true,
"rootDirs": ["src"],
"pretty": true,
"sourceMap": true
},
"exclude": [".eslintrc.js", ".prettierrc.js", "jest.config.js"],
"ts-node": {
"files": true
},
"exclude": [".eslintrc.js", ".prettierrc.js"]
}
5 changes: 0 additions & 5 deletions packages/compositor-proxy/jest.config.js

This file was deleted.

33 changes: 14 additions & 19 deletions packages/compositor-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,30 @@
"generate": "yarn run rimraf src/protocol/*.js && yarn run mkdirp src/protocol && yarn generate:wayland && yarn generate:wayland-drm && yarn generate:xdgshell",
"build:native": "yarn run mkdirp build && cmake -G Ninja -B./build -S./ && ninja -C ./build install",
"build:typescript": "yarn run tsc",
"build": "yarn run rimraf dist types && yarn build:native && yarn build:typescript",
"test": "yarn run jest"
"build": "yarn run rimraf dist types && yarn build:native && yarn build:typescript"
},
"dependencies": {
"@gfld/xtsb": "workspace:^",
"ws": "^8.14.2"
"ws": "^8.16.0"
},
"devDependencies": {
"@gfld/compositor-proxy-generator": "workspace:^",
"@tsconfig/node18": "^18.2.2",
"@types/jest": "^29.5.5",
"@types/js-yaml": "^4.0.6",
"@types/jsonwebtoken": "^9.0.3",
"@types/node": "^18.18.7",
"@types/ws": "^8.5.6",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"@types/js-yaml": "^4.0.9",
"@types/node": "^18.19.17",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"cpy-cli": "^5.0.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"json-schema-to-typescript": "^13.1.1",
"json-schema-to-typescript": "^13.1.2",
"mkdirp": "^3.0.1",
"prettier": "^3.0.3",
"rimraf": "^5.0.4",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"typescript": "^5.3.3"
},
"author": "Erik De Rijcke",
"homepage": "https://www.greenfield.app",
Expand Down
6 changes: 3 additions & 3 deletions packages/compositor-proxy/src/FrameFeedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ configureFramePipelineTicks(nextTickInterval)
export class FrameFeedback {
private serverProcessingDurations: number[] = []
private clientProcessingDuration = 0
private clientFeedbackTimestamp = 0
private clientFeedbackTimestamp = performance.now()
private parkedFeedbackClockQueue: Feedback[] = []
private frameCallbackDelay = 0
private destroyed = false
Expand All @@ -67,8 +67,8 @@ export class FrameFeedback {
}

commitNotify(frameCallbacksIds: number[]): void {
const clockQueue =
performance.now() - this.clientFeedbackTimestamp > 1500 ? this.parkedFeedbackClockQueue : feedbackClockQueue
const assumeStalledCompositor = performance.now() - this.clientFeedbackTimestamp > 1500
const clockQueue = assumeStalledCompositor ? this.parkedFeedbackClockQueue : feedbackClockQueue
clockQueue.push({
callback: (time) => {
if (this.destroyed) {
Expand Down
4 changes: 2 additions & 2 deletions packages/compositor-proxy/src/SessionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function channel(session: Session, request: AppRequest, ws: WebSocket, url: URL)
}

channel.doOpen(ws)
logger.info(`channel (re)connection from ${url.href})}`)
logger.info(`Opened connection from ${url.href})}`)

ws.onmessage = (event) => {
channel.doMessage(event.data as Buffer)
Expand All @@ -284,7 +284,7 @@ function channel(session: Session, request: AppRequest, ws: WebSocket, url: URL)
if (channel) {
channel.ws = undefined
}
logger.info(`Data connection closed. Code: ${event.code}. Message: ${event.reason}`)
logger.info(`Closed connection from ${url.href}). Code: ${event.code}. Message: ${event.reason}`)
}
}

Expand Down
8 changes: 3 additions & 5 deletions packages/compositor-proxy/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
"pretty": true,
"declarationDir": "types",
"outDir": "dist",
"declaration": true
},
"exclude": [".eslintrc.js", ".prettierrc.js", "jest.config.js"],
"ts-node": {
"files": true
"declaration": true,
"sourceMap": true,
},
"exclude": [".eslintrc.js", ".prettierrc.js"]
}
Loading

0 comments on commit 99dea7e

Please sign in to comment.