Release Kaleido 0.1.10 with native Original playback and PCM compatibility
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m45s

This commit is contained in:
Elijah 2026-10-26 16:42:19 -07:00
parent 784921dba9
commit 2a83fe0db5
23 changed files with 721 additions and 43 deletions

View file

@ -0,0 +1,28 @@
"""Compare optimized release builds on one authorized device at a time."""
import argparse,json,pathlib,re,statistics,subprocess,sys,time
from device import adb,DEVICE,OUT
from verify_ui import wait,labels,focus
def main():
p=argparse.ArgumentParser();p.add_argument('label');p.add_argument('--cycles',type=int,default=3);p.add_argument('--nav-cycles',type=int,default=1)
args=p.parse_args();folder=OUT/'release-comparison';folder.mkdir(exist_ok=True)
package=adb('shell','dumpsys','package','tv.kaleido.app').decode()
assert 'DEBUGGABLE' not in re.search(r'pkgFlags=\[(.*?)\]',package)[1],'Performance tests require a release APK'
assert 'status=speed-profile' in package,'Apply the matching ART profile before comparison'
result={'device':DEVICE,'version':re.search(r'versionName=(\S+)',package)[1],'startup':[]}
adb('shell','input','keyevent','KEYCODE_WAKEUP')
for i in range(args.cycles):
adb('shell','am','force-stop','tv.kaleido.app');start=time.monotonic()
raw=adb('shell','am','start','-W','-n','tv.kaleido.app/.MainActivity').decode()
wait(lambda r:'Continue Watching' in labels(r) and focus(r)=='Home' and
all(n.get('content-desc')!='Kaleido starting' for n in r.iter('node')),'Cold Home ready',timeout=45)
row={'homeReadySeconds':round(time.monotonic()-start,3)}
row.update({k:int(v) for k,v in re.findall(r'(ThisTime|TotalTime|WaitTime): (\d+)',raw)})
result['startup'].append(row);print('STARTUP',args.label,i+1,row,flush=True)
result['medianHomeReadySeconds']=statistics.median(r['homeReadySeconds'] for r in result['startup'])
result['medianActivityMs']=statistics.median(r['TotalTime'] for r in result['startup'])
(folder/(args.label+'.json')).write_text(json.dumps(result,indent=2))
nav=subprocess.run([sys.executable,str(pathlib.Path(__file__).with_name('profile_transitions.py')),args.label,'--cycles',str(args.nav_cycles)])
if nav.returncode:raise SystemExit(nav.returncode)
print('COMPLETE',args.label,'activity median',result['medianActivityMs'],'Home median',result['medianHomeReadySeconds'],flush=True)
if __name__=='__main__':main()

View file

@ -0,0 +1,76 @@
"""Exercise the actual release UI, measure startup/rebuffering, restore resume time."""
import argparse,json,os,pathlib,re,shlex,time,urllib.parse,urllib.request
if pathlib.Path('/etc/ssl/cert.pem').exists():os.environ.setdefault('SSL_CERT_FILE','/etc/ssl/cert.pem')
from device import adb,OUT,DEVICE
from verify_ui import launch,key,focused,wait,labels,focus,snapshot
from inspect_server import get,base,token
def session():
raw=adb('shell','dumpsys','media_session').decode(errors='replace')
m=re.search(r'package=tv\.kaleido\.app.*?PlaybackState \{state=(\w+)\(\d+\), position=(\d+).*?speed=([\d.]+), updated=(\d+)',raw,re.S)
return {'state':m[1],'position':int(m[2]),'speed':float(m[3]),'updated':int(m[4])} if m else {}
def main():
p=argparse.ArgumentParser();p.add_argument('label');p.add_argument('id');p.add_argument('--seconds',type=int,default=60);args=p.parse_args()
folder=OUT/'release-comparison';folder.mkdir(exist_ok=True)
pkg=adb('shell','dumpsys','package','tv.kaleido.app').decode()
assert 'DEBUGGABLE' not in re.search(r'pkgFlags=\[(.*?)\]',pkg)[1]
assert 'status=speed-profile' in pkg
before=get('/library/metadata/'+args.id)['Metadata'][0];title=before['title']
(folder/(args.label+'-before.json')).write_text(json.dumps(before,indent=2))
# A previous ADB tap can leave Android in touch mode across app restarts.
adb('shell','input','keyevent','19')
launch()
for target in ['Movies','TV Shows','Search']:key(22);focused(target)
key(23);wait(lambda r:'Movies, shows, episodes' in labels(r),'Search field')
adb('shell','input','text',shlex.quote(title.replace(' ','%s')))
wait(lambda r:title in labels(r),'Matching search result')
ime=adb('shell','dumpsys','input_method').decode(errors='replace')
if re.search(r'mInputShown=true|isInputViewShown=true',ime):key(4)
# EditText has the same text as the result; Tab exits editing without entering
# Android touch mode, and the focused poster is verified before activation.
key(61)
wait(lambda r:any(n.get('focused')=='true' and n.get('class')!='android.widget.EditText' and title in labels(n) for n in r.iter('node')),'Movie result focus')
key(23)
root=wait(lambda r:any(s=='Play' or s.startswith('Resume') for s in labels(r)),'Movie actions')
wait(lambda r:focus(r)=='Play' or focus(r).startswith('Resume'),'Playback action focus')
if 'Start over' in labels(root):key(22);focused('Start over')
print('PLAYBACK_START',args.label,flush=True)
adb('logcat','-c');start=time.monotonic();key(23)
ready=None;samples=[];ready_logs=''
while time.monotonic()-start<70:
s=session();s['elapsed']=round(time.monotonic()-start,3);samples.append(s)
ready_logs=adb('logcat','-d','-s','KaleidoPlayback:I','AndroidRuntime:E','*:S').decode(errors='replace')
if s.get('state')=='PLAYING' and 'READY item='+args.id in ready_logs:ready=s['elapsed'];break
time.sleep(.7)
assert ready is not None,'Release playback did not become ready'
print('PLAYBACK_READY',args.label,ready,flush=True)
steady_start=time.monotonic();last='PLAYING';rebuffers=0
while time.monotonic()-steady_start<args.seconds:
s=session();s['elapsed']=round(time.monotonic()-start,3);samples.append(s)
if s.get('state')=='BUFFERING' and last!='BUFFERING':rebuffers+=1
last=s.get('state');time.sleep(1)
(folder/(args.label+'-measurement.json')).write_text(json.dumps({'readySeconds':ready,'rebufferTransitions':rebuffers,'samples':samples},indent=2))
(folder/(args.label+'-surface.txt')).write_bytes(adb('shell','dumpsys','SurfaceFlinger'))
adb('shell','input','keyevent','127');time.sleep(1)
(folder/(args.label+'-player.png')).write_bytes(adb('exec-out','screencap','-p'))
for _ in range(2):key(4)
wait(lambda r:any(s in labels(r) for s in ['Continue Watching','Mark watched','Mark unwatched']),'Return to the originating page after playback')
logs=adb('logcat','-d','-s','KaleidoPlayback:I','AndroidRuntime:E','*:S').decode(errors='replace')
(folder/(args.label+'-playback.log')).write_text(logs)
# Release builds use normal Plex progress reporting. Restore the prior resume time.
time.sleep(1)
query=urllib.parse.urlencode({'key':args.id,'time':int(before.get('viewOffset') or 0),'state':'stopped','identifier':'com.plexapp.plugins.library'})
req=urllib.request.Request(base.rstrip('/')+'/:/progress?'+query,headers={'X-Plex-Token':token})
with urllib.request.urlopen(req,timeout=30) as r:r.read()
after=get('/library/metadata/'+args.id)['Metadata'][0]
result={'device':DEVICE,'version':re.search(r'versionName=(\S+)',pkg)[1],'id':args.id,'readySeconds':ready,
'rebufferTransitions':rebuffers,'readyEvents':logs.count('READY item='+args.id+' '),'samples':samples,
'resumeRestored':int(after.get('viewOffset') or 0)==int(before.get('viewOffset') or 0),
'viewCountUnchanged':after.get('viewCount')==before.get('viewCount')}
(folder/(args.label+'-playback.json')).write_text(json.dumps(result,indent=2))
print(json.dumps({k:v for k,v in result.items() if k!='samples'}),flush=True)
assert 'FATAL EXCEPTION' not in logs and 'ERROR code=' not in logs,'Playback error in release'
assert result['resumeRestored'] and result['viewCountUnchanged'],'Plex progress restoration needs attention'
launch()
if __name__=='__main__':main()

View file

@ -0,0 +1,28 @@
"""Inventory real Plex formats. Raw metadata stays in ignored private evidence."""
import collections,json,os,pathlib,urllib.parse
if pathlib.Path('/etc/ssl/cert.pem').exists():os.environ.setdefault('SSL_CERT_FILE','/etc/ssl/cert.pem')
from inspect_server import get
OUT=pathlib.Path(__file__).resolve().parents[1]/'evidence/private/playback-validation'
OUT.mkdir(parents=True,exist_ok=True)
def main():
sections=get('/library/sections').get('Directory',[])
(OUT/'sections.json').write_text(json.dumps(sections,indent=2))
items=[]
for section in sections:
if section.get('type') not in ('movie','show','artist'):continue
kind={'movie':'1','show':'4','artist':'10'}[section['type']]
start=0
while True:
params={'type':kind,'includeMedia':'1','includeMediaAnalysis':'1','X-Plex-Container-Start':start,'X-Plex-Container-Size':200}
data=get('/library/sections/'+section['key']+'/all?'+urllib.parse.urlencode(params))
batch=data.get('Metadata',[])
for item in batch:item['_section']=section['key']
items.extend(batch);start+=len(batch)
if not batch or start>=int(data.get('totalSize',start)):break
print('Inventoried',section['type'],start,'items',flush=True)
(OUT/'inventory.json').write_text(json.dumps(items))
for label,field in [('Video','videoCodec'),('Audio','audioCodec'),('Containers','container')]:
counts=collections.Counter(media.get(field,'none') for item in items for media in item.get('Media',[]))
print(label,dict(counts),flush=True)
if __name__=='__main__':main()

View file

@ -26,7 +26,7 @@ def ready(item,timeout=45):
def controls():
adb('shell','am','force-stop','tv.kaleido.app');adb('logcat','-c')
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId','7599','--el','testOffset','90000','--ei','testMode','1')
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId','7599','--el','testOffset','90000','--ei','testMode','1','--ez','testValidation','true')
ready(7599);key(127);focused('Play')
screenshot('direct-stream-episode')
key(4);wait(lambda r:not labels(r),'One Back must hide controls rather than only clearing focus')
@ -67,7 +67,7 @@ def episode():
item=titles[0];expected=str(titles[1]['ratingKey'])
adb('shell','am','force-stop','tv.kaleido.app')
adb('logcat','-c')
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId',str(item['ratingKey']),'--el','testOffset','90000','--ei','testMode','2')
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId',str(item['ratingKey']),'--el','testOffset','90000','--ei','testMode','2','--ez','testValidation','true')
time.sleep(9);key(127);focused('Play')
for _ in range(6):
if 'Next episode' in focus(snapshot()):break
@ -82,12 +82,12 @@ def episode():
assert 'item='+expected in logs,'Next episode did not become the active player'
print('PASS next episode replaced player with expected title')
def postplay():
def postplay(mode=2):
from inspect_server import get
item=get('/library/metadata/7599?includeMarkers=1')['Metadata'][0]
adb('shell','am','force-stop','tv.kaleido.app');adb('logcat','-c')
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId','7599','--el','testOffset',str(item['duration']-12000),'--ei','testMode','2')
deadline=time.monotonic()+45
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId','7599','--el','testOffset',str(item['duration']-12000),'--ei','testMode',str(mode),'--ez','testValidation','true')
deadline=time.monotonic()+(90 if mode<=0 else 45)
while time.monotonic()<deadline:
time.sleep(1)
logs=adb('logcat','-d','-s','KaleidoPlayback:I','AndroidRuntime:E','*:S').decode(errors='replace')
@ -104,7 +104,7 @@ def credits():
item=get('/library/metadata/7599?includeMarkers=1')['Metadata'][0]
marker=next(m for m in item['Marker'] if m['type']=='credits')
adb('shell','am','force-stop','tv.kaleido.app');adb('logcat','-c')
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId','7599','--el','testOffset',str(marker['startTimeOffset']+2000),'--ei','testMode','2')
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId','7599','--el','testOffset',str(marker['startTimeOffset']+2000),'--ei','testMode','2','--ez','testValidation','true')
time.sleep(6);key(127);focused('Play');key(19);focused('Playback timeline');key(19);focused('Skip credits')
screenshot('skip-credits-contrast');key(23)
deadline=time.monotonic()+8
@ -125,4 +125,4 @@ def credits():
(OUT/'postplay-cancel.log').write_text(logs)
print('PASS skip credits -> postplay, episode/related rows, cancellable autoplay')
globals()[sys.argv[1]]()
if __name__=='__main__':globals()[sys.argv[1]]()

View file

@ -0,0 +1,126 @@
"""Exercise real Plex playback through Kaleido's opt-in debug validation mode.
One device at a time. No timeline/scrobble writes in validation mode. Raw reports
and screenshots remain private; source media and track preferences are untouched.
"""
import argparse,json,os,pathlib,subprocess,time
if pathlib.Path('/etc/ssl/cert.pem').exists():os.environ.setdefault('SSL_CERT_FILE','/etc/ssl/cert.pem')
from device import adb,DEVICE,OUT
from inspect_server import get
def audit():
try:raw=adb('exec-out','run-as','tv.kaleido.app','cat','files/playback-validation.jsonl')
except RuntimeError:return b'',[]
records=[]
for line in raw.splitlines():
try:records.append(json.loads(line))
except json.JSONDecodeError:pass # The writer can be appending its last line.
return raw,records
def snapshot_signal():
command='for p in /sys/class/amhdmitx/amhdmitx0/attr /sys/class/amhdmitx/amhdmitx0/hdmi_hdr_status /sys/class/amhdmitx/amhdmitx0/hdr_status /sys/class/video/frame_format /sys/module/amdolby_vision/parameters/dolby_vision_status /sys/module/amdolby_vision/parameters/dolby_vision_mode; do if [ -r "$p" ]; then printf "%s=" "$p"; cat "$p"; fi; done'
return adb('shell',command)
def watched(item):return {k:item.get(k) for k in ('viewOffset','viewCount','lastViewedAt')}
def main():
parser=argparse.ArgumentParser()
parser.add_argument('id');parser.add_argument('label');parser.add_argument('--mode',type=int,default=-1)
parser.add_argument('--seconds',type=float,default=12);parser.add_argument('--offset',type=int,default=90000)
parser.add_argument('--seek',action='store_true');parser.add_argument('--screenshot',action='store_true')
parser.add_argument('--observe-hdmi',action='store_true',help='Read the already tuned TCL debug HDMI observer during ONN playback')
parser.add_argument('--fixture',type=pathlib.Path,help='Private local test media with a matching .json metadata file; bypasses Plex transport')
parser.add_argument('--expect-mode',type=int,choices=(0,1,2))
parser.add_argument('--expect-width',type=int)
parser.add_argument('--expect-channels',type=int)
parser.add_argument('--expect-audio-encoding',type=int)
args=parser.parse_args()
folder=OUT/'playback-validation'/('onn' if DEVICE=='192.168.50.195:5555' else 'tcl')/args.label
folder.mkdir(parents=True,exist_ok=True)
before=json.loads(args.fixture.with_suffix('.json').read_text()) if args.fixture else get('/library/metadata/'+args.id)['Metadata'][0]
expects_video=any(m.get('videoCodec') for m in before.get('Media',[]))
(folder/'source.json').write_text(json.dumps(before,indent=2))
adb('shell','input','keyevent','KEYCODE_WAKEUP')
adb('shell','am','force-stop','tv.kaleido.app')
adb('shell','run-as','tv.kaleido.app','rm','-f','files/playback-validation.jsonl')
if args.fixture:
name=args.fixture.stem
if not name.replace('-','').isalnum() or name.lower()!=name:raise SystemExit('Use a lowercase alphanumeric fixture name')
adb('shell','run-as','tv.kaleido.app','mkdir','-p','files/validation')
for path in (args.fixture,args.fixture.with_suffix('.json')):
tmp='/data/local/tmp/kaleido-validation-'+path.name
adb('push',str(path),tmp)
adb('shell','run-as','tv.kaleido.app','cp',tmp,'files/validation/'+path.name)
adb('shell','rm','-f',tmp)
start=time.monotonic()
if args.fixture:adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testFixture',args.fixture.stem)
else:adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId',args.id,'--el','testOffset',str(args.offset),'--ei','testMode',str(args.mode),'--ez','testValidation','true')
ready=None;records=[]
while time.monotonic()-start<55:
_,records=audit()
if args.fixture and any(r['event'] in ('error','prepareFailure') for r in records):break
samples=[r for r in records if r['event']=='sample']
if samples:
last=samples[-1]
video=last.get('videoCounters',{})
if last.get('playing') and (video.get('rendered',0)>5 or not expects_video and any(r['event']=='audioAdvancing' for r in records)):
ready=round(time.monotonic()-start,2);break
time.sleep(.8)
if ready is not None:time.sleep(args.seconds)
raw,records=audit();(folder/'audit-steady.jsonl').write_bytes(raw)
(folder/'signal-steady.txt').write_bytes(snapshot_signal())
(folder/'surface-steady.txt').write_bytes(adb('shell','dumpsys','SurfaceFlinger'))
if args.observe_hdmi:
import device
original=device.DEVICE
try:
device.DEVICE='192.168.50.200:5555'
(folder/'tcl-hdmi.jsonl').write_bytes(adb('exec-out','run-as','tv.kaleido.app','cat','files/hdmi-validation.jsonl'))
(folder/'tcl-picture.png').write_bytes(adb('exec-out','screencap','-p'))
finally:device.DEVICE=original
if args.screenshot:(folder/'onn-picture.png').write_bytes(adb('exec-out','screencap','-p'))
seek_result=None
if args.seek and ready is not None:
adb('shell','input','keyevent','127');time.sleep(1.5)
_,paused=audit();old=[r for r in paused if r['event']=='sample'][-1]['position']
for _ in range(3):
_,current=audit();position=[r for r in current if r['event']=='sample'][-1]['position']
adb('shell','input','keyevent','89')
deadline=time.monotonic()+25
while time.monotonic()<deadline:
time.sleep(.8);_,check=audit();sample=[r for r in check if r['event']=='sample'][-1]
if sample['state']==3 and abs(sample['position']-(position-10000))<2200:break
_,rewound=audit();new=[r for r in rewound if r['event']=='sample'][-1]['position']
adb('shell','input','keyevent','126');time.sleep(3)
seek_result={'from':old,'to':new,'expectedDelta':-30000,'correct':abs((old-new)-30000)<2500}
for _ in range(3):
adb('shell','input','keyevent','4');time.sleep(.8)
_,r=audit()
if any(x['event']=='closed' for x in r):break
time.sleep(1)
raw,records=audit();(folder/'audit.jsonl').write_bytes(raw)
samples=[r for r in records if r['event']=='sample']
steady=[r for r in samples if r.get('playing')]
last=steady[-1] if steady else {}
after=before if args.fixture else get('/library/metadata/'+args.id)['Metadata'][0]
result={'label':args.label,'id':args.id,'device':DEVICE,'requestedMode':args.mode,'readySeconds':ready,
'firstFrame':any(r['event']=='firstFrame' for r in records),'audioAdvancing':any(r['event']=='audioAdvancing' for r in records),
'videoDecoders':[r['name'] for r in records if r['event']=='videoDecoder'],
'audioDecoders':[r['name'] for r in records if r['event']=='audioDecoder'],
'audioTracks':[r for r in records if r['event']=='audioTrack'],
'errors':[r['code'] for r in records if r['event']=='error'],'errorDetails':[r for r in records if r['event'] in ('error','prepareFailure')],'finalSample':last,'seek':seek_result,
'expectsVideo':expects_video,'videoRendered':not expects_video or any(r.get('videoCounters',{}).get('rendered',0)>5 for r in samples),
'closed':any(r['event']=='closed' for r in records),'before':watched(before),'after':watched(after),
'transport':'private-local-fixture' if args.fixture else 'Plex','progressUnchanged':None if args.fixture else watched(before)==watched(after)}
(folder/'result.json').write_text(json.dumps(result,indent=2))
print(json.dumps({k:result[k] for k in ('label','readySeconds','firstFrame','audioAdvancing','videoDecoders','errors','progressUnchanged')}),flush=True)
print('Output:',last.get('video'),last.get('audio'),'mode:',last.get('mode'),'seek:',seek_result,flush=True)
if ready is None:raise SystemExit('Playback did not become ready; see private evidence')
if not result['closed']:raise SystemExit('Player did not close cleanly')
if result['progressUnchanged'] is False:raise SystemExit('Unexpected progress change; see before/after evidence')
if args.seek and not seek_result['correct']:raise SystemExit('Seek did not reach the expected absolute position')
if args.expect_mode is not None and last.get('mode')!=args.expect_mode:raise SystemExit('Unexpected delivery mode')
if args.expect_width is not None and last.get('video',{}).get('width')!=args.expect_width:raise SystemExit('Unexpected delivered video width')
if args.expect_channels is not None and last.get('audio',{}).get('channels')!=args.expect_channels:raise SystemExit('Unexpected delivered audio channel count')
if args.expect_audio_encoding is not None and (not result['audioTracks'] or result['audioTracks'][-1]['encoding']!=args.expect_audio_encoding):raise SystemExit('Unexpected audio output encoding')
if __name__=='__main__':main()

View file

@ -72,7 +72,7 @@ def position():
def player():
adb('shell','am','force-stop','tv.kaleido.app');adb('logcat','-c')
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId','9776','--el','testOffset','90000','--ei','testMode','2')
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId','9776','--el','testOffset','90000','--ei','testMode','2','--ez','testValidation','true')
# A pause sent while the player is still preparing is overridden when playback starts.
deadline=time.monotonic()+45
while 'READY item=9776' not in adb('logcat','-d','-s','KaleidoPlayback:I').decode(errors='replace'):