Release Preview 20 shared desktop, Android and Sargo updates

Restore Gaia settings and media workflows, extend native network adapters, and align the APK payload. Generate French/English changelogs and website entries from the simplified JSON source.

Validation: shared JS and Tundra unit tests; desktop workflows and persistence; signed APK payload parity; Sargo RAM and installed startup with boot readback. Android runtime qualification is recorded separately.
This commit is contained in:
OverSu 2026-10-13 00:19:45 +02:00
commit 1311bed5e9
170 changed files with 19698 additions and 2495 deletions

View file

@ -10,15 +10,20 @@ function deferred() {
}
// Execute the shared adapter, with controllable media promises instead of a sensor.
function setup(native = false) {
function setup(native = false, platformName = 'desktop') {
const videos = [], streams = [], requests = [], events = new EventTarget();
const nativeRequests=[];
let hidden = false, captureGate, playGate, labels = true;
const nativeRequests=[], wakeLocks=[];
let hidden = false, captureGate, playGate, labels = true, requireStopped = false;
const failures=[];
class Document extends EventTarget { get hidden() { return hidden; } }
class Video {
get srcObject() { return this.stream; }
set srcObject(value) { this.stream = value; }
constructor() { this.dataset = {}; this.style = {}; }
set srcObject(value) {
if(requireStopped && value===null && this.stream?.getTracks().some(t=>t.readyState!=="ended"))
throw Error("Capture producer is still live");
this.stream = value;
}
constructor() { this.dataset = {}; this.style = {}; this.parentNode={append:canvas=>{canvas.isConnected=true;}}; }
play() { return playGate?.promise || Promise.resolve(); }
pause() {}
remove() { const index=videos.indexOf(this); if(index!==-1)videos.splice(index, 1); }
@ -27,19 +32,22 @@ function setup(native = false) {
Object.assign(document, {
documentElement: {lang:'en'}, body: {append:video => videos.push(video)},
querySelector: () => null, querySelectorAll: () => [...videos],
createElement: tag => tag === 'canvas' ? {getContext:()=>({
createShader:()=>({}), shaderSource(){}, compileShader(){},
getShaderParameter:()=>false, createProgram:()=>({}),
deleteShader(){}, deleteProgram(){}, getExtension:()=>null,
})} : new Video(),
createElement: tag => tag === 'canvas' ? {style:{},dataset:{},
remove(){this.isConnected=false;},
captureStream(){throw Error('Native preview must not recapture the canvas');},
getContext:()=>new Proxy({
getShaderParameter:()=>native==='working',getProgramParameter:()=>true,
},{get(target,name){return target[name] || (()=>({}));}}),
} : new Video(),
});
const navigator = {language:'en', mediaDevices: {
const navigator = {requestWakeLock(topic){const lock={topic,released:false,unlock(){this.released=true;}};wakeLocks.push(lock);return lock;},language:'en', mediaDevices: {
async enumerateDevices() {
return ['rear','selfie'].map(deviceId => ({kind:'videoinput', deviceId,
label: labels ? (deviceId === 'rear' ? 'Back camera' : 'Front camera') : ''}));
},
async getUserMedia(constraints) {
requests.push(constraints);
if(failures.length) throw failures.shift();
const id = constraints.video.deviceId?.exact ||
(constraints.video.facingMode?.ideal === 'user' ? 'selfie' : 'rear');
const gate = captureGate;
@ -57,19 +65,23 @@ function setup(native = false) {
const context = {document, Document, navigator, HTMLMediaElement:Video, console, performance,
location:{hostname:'camera.localhost',port:'8765'}, parent:{},
MutationObserver:class {observe() {}},
Event, DOMException, CustomEvent:class extends Event {constructor(type,opts){super(type);this.detail=opts.detail;}},
Event, DOMException, MediaStream:class extends EventTarget {getTracks(){return [];}getVideoTracks(){return [];}}, CustomEvent:class extends Event {constructor(type,opts){super(type);this.detail=opts.detail;}},
setTimeout, clearTimeout, queueMicrotask, setInterval:()=>0, clearInterval(){},
addEventListener:events.addEventListener.bind(events), dispatchEvent:events.dispatchEvent.bind(events),
VulpesCompat:{async call(method,params) {
if(method==='platform.capabilities')return {platform:native?'tundra':'desktop',camera:true};
if(method==='platform.capabilities')return {platform:native?'tundra':platformName,camera:true};
nativeRequests.push(params);
if(params.action==='start')return {session:42,width:640,height:480,orientation:90};
if(params.action==='start')return {session:nativeRequests.length,width:640,height:480,orientation:90,focusModes:['fixed'],zoomRatios:[1],pictureSizes:[{width:640,height:480}]};
if(params.action==='frame')return {sequence:nativeRequests.length,data:new ArrayBuffer(640*480*3/2)};
}},
};
context.window = context;
vm.runInNewContext(readFileSync(new URL('../host/gaia-camera.js', import.meta.url),'utf8'), context);
return {api:navigator.mozCameras, streams, requests, videos, nativeRequests,
return {api:navigator.mozCameras, streams, requests, videos, nativeRequests, wakeLocks,
viewfinder:()=>{const video=new Video();videos.push(video);return video;},
failCapture:error=>failures.push(error),
unlabelled:()=>{labels=false;},
requireStoppedBeforeDetach:()=>{requireStopped=true;},
blockCapture:()=>captureGate=deferred(), blockPlay:()=>playGate=deferred(),
hide:()=>{hidden=true;events.dispatchEvent(new Event('visibilitychange'));},
show:()=>{hidden=false;events.dispatchEvent(new Event('visibilitychange'));},
@ -90,7 +102,7 @@ test('native preview setup failure releases the sensor before returning an error
await assert.rejects(s.api.getCamera('front'),/Camera shader compilation failed/);
assert.equal(s.nativeRequests.length,2);
assert.equal(s.nativeRequests[1].action,'stop');
assert.equal(s.nativeRequests[1].session,42);
assert.equal(s.nativeRequests[1].session,1);
});
test('switch waits for asynchronous close even after release has detached the current stream', async()=>{
@ -150,3 +162,95 @@ test('hide/show during preview startup leaves no live abandoned stream', async()
assert.equal(camera.getTracks()[0].readyState,'live');
await camera.release();
});
test('release stops capture tracks before detaching the preview video',async()=>{
const s=setup();s.requireStoppedBeforeDetach();
const {camera}=await s.api.getCamera('back');
await camera.release();
assert.equal(camera.getTracks()[0].readyState,'ended');
const next=await s.api.getCamera('front');
await next.camera.release();
});
test('release announces stopped before the next camera starts',async()=>{
const s=setup(), {camera}=await s.api.getCamera('back');
const states=[];camera.addEventListener('previewstatechange',e=>states.push(e.newState));
await camera.release();await camera.release();
assert.deepEqual(states,['stopped']);
});
test('Gaia viewfinder recomputes a viewport that was hidden at initialization',()=>{
let view;
const window={innerWidth:0,innerHeight:0};
vm.runInNewContext(readFileSync(new URL('../gaia/apps/camera/js/views/viewfinder.js',import.meta.url),'utf8'),{
window,define(factory){const module={};factory(name=>name==='view'?{extend:value=>value}:name==='debug'?()=>()=>{}:{},{},module);view=module.exports;},
});
const sizes=[];
const instance=Object.assign({},view,{updatePreviewMetrics(){sizes.push([this.container.width,this.container.height]);}});
instance.getSize();instance.updatePreview({width:480,height:640},0,false);
assert.equal(sizes.length,0,'hidden window must not produce a zero-size video');
window.innerWidth=360;window.innerHeight=666;
instance.updatePreview({width:480,height:640},0,false);
window.innerWidth=696;window.innerHeight=330;
instance.updatePreview({width:480,height:640},0,false);
assert.deepEqual(sizes,[[360,666],[696,330]]);
});
test('native preview uses one canvas, releases its worker and never recaptures video',async()=>{
const s=setup('working');
const {camera:first}=await s.api.getCamera('back');
const canvas=first.vulpesPreviewCanvas;
assert.ok(first.vulpesTiming.frames>0);
assert.equal(first.vulpesClosed,false);
await first.release();
assert.equal(first.vulpesClosed,true);
const {camera:second}=await s.api.getCamera('front');
assert.equal(second.vulpesPreviewCanvas,canvas);
assert.equal(second.vulpesClosed,false);
await second.release();
assert.equal(s.nativeRequests.filter(r=>r.action==='stop').length,2);
assert.equal(s.wakeLocks.length,2);
assert.ok(s.wakeLocks.every(lock=>lock.topic==='screen' && lock.released));
});
test('native preview attaches inside Gaia and detaches on camera release',async()=>{
const s=setup('working'),video=s.viewfinder();
const {camera}=await s.api.getCamera('front');
video.mozSrcObject=camera;
await video.play();
assert.equal(video.mozSrcObject,camera);
assert.equal(video.srcObject,undefined,'do not create a native video decoder');
assert.equal(camera.vulpesPreviewCanvas.isConnected,true);
assert.equal(video.style.display,'none');
await camera.release();
assert.equal(camera.vulpesPreviewCanvas.isConnected,false);
assert.equal(video.style.display,'');
assert.equal(camera.vulpesClosed,true);
});
test('Android waits for a busy camera without changing the selected sensor', async()=>{
const s=setup(false,'android');
await s.api.getCamera('back');
s.failCapture(new DOMException('closing','NotReadableError'));
const {camera}=await s.api.getCamera('front');
assert.equal(camera.getVideoTracks()[0].getSettings().deviceId,'selfie');
assert.equal(s.requests.length,3);
assert.equal(s.requests[1].video.deviceId.exact,s.requests[2].video.deviceId.exact);
await camera.release();
});
test('Android does not retry camera permission refusal',async()=>{
const s=setup(false,'android');s.failCapture(new DOMException('denied','NotAllowedError'));
await assert.rejects(s.api.getCamera('back'),{name:'NotAllowedError'});
assert.equal(s.requests.length,1);
});
test('Android stops camera retry when the app becomes hidden',async()=>{
const s=setup(false,'android');s.failCapture(new DOMException('closing','NotReadableError'));
const pending=s.api.getCamera('front');
const checked=assert.rejects(pending,{name:'AbortError'});
await new Promise(resolve=>setImmediate(resolve));s.hide();await checked;
assert.equal(s.requests.length,1);
});