Workers.js 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171
  1. const defaultLogger = {
  2. info: console.log,
  3. debug: console.log,
  4. error: console.error,
  5. infoAndReportMeasurement: (...i)=>{}
  6. };
  7. const USER_ID = "987412365"
  8. , PAGE_SESSION = "aaabbbccc"
  9. , SERVER_SESSION = "cccbbbaaa"
  10. , COS_PREFIX = "error-bitstreams-auto-uploaded-from-application/"
  11. , FRAME_COMPOSE_LENGTH = 5;
  12. import CircularArray from "./CircularArray.js"
  13. export default class Workers {
  14. constructor(e, t) {
  15. this.rtcp = e,
  16. this.cacheSize = 0,
  17. this.cacheBuffer = new Uint8Array(262144),
  18. this.cacheFrameCnt = 0,
  19. this.startReceiveTime = 0,
  20. this.cacheFrameComposes = new Array(0),
  21. this.cacheSizes = new Array(5).fill(0),
  22. this.cacheFrameCnts = new Array(5).fill(-1),
  23. this.cacheStartReceiveTimes = new Array(5).fill(0),
  24. this.cacheBuffers = [new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144)],
  25. this.panoCacheSize = 0,
  26. this.panoCacheBuffer = new Uint8Array(2097152),
  27. this.cachePanoTileID = 0,
  28. this.receivedMedia = 0,
  29. this.receivedMedia_worker = 0,
  30. this.receivedYUV = 0,
  31. this.receivedEmit = 0,
  32. this.returnFrames = 0,
  33. this.lastReturnFrames = 0,
  34. this.lastReceivedEmit = 0,
  35. this.mediaBytesReceived = 0,
  36. this.metaBytesReceived = 0,
  37. this.noWasmBytesReceived = 0,
  38. this.rtcBytesReceived = 0,
  39. this.rtcMessageReceived = 0,
  40. this.packetsDrop = 0,
  41. this.framesAwait = 0,
  42. this.sendOutBuffer = 0,
  43. this.decodeTimePerFrame = 0,
  44. this.decodeTimeMaxFrame = 0,
  45. this.lastRenderTs = 0,
  46. this.JankTimes = 0,
  47. this.bigJankTimes = 0,
  48. this.DecodeJankTimes = 0,
  49. this.bigDecodeJankTimes = 0,
  50. this.saveframe = !1,
  51. this.SaveMediaStream = !1,
  52. this.packetsLost = 0,
  53. this.showAllReceivedMetadata = !1,
  54. this.firstMediaArraval = 0,
  55. this.firstMediaReceived = !1,
  56. this.firstYUVDecoded = 0,
  57. this.firstRender = 0,
  58. this.firstYUVReceived = !1,
  59. this.reconnectSignal = !1,
  60. this.serverFrameSlow = 0,
  61. this.serverFrameFast = 0,
  62. this.clientFrameSlow = 0,
  63. this.clientFrameFast = 0,
  64. this.lastServerTS = 0,
  65. this.lastClientTS = 0,
  66. this.lastSeq = 0,
  67. this.lastIsPureMeta = !1,
  68. this.lastHBPacketTs = 0,
  69. this.HBPacketInterval = 0,
  70. this.lastHBPacketSrvSentTs = 0,
  71. this.HBPacketIntervalSrvSent = 0,
  72. this.cachedLength = 2,
  73. this.cachedStreams = new Array(this.cachedLength),
  74. this.cachedMetas = new Array(this.cachedLength),
  75. this.cachedPtss = new Array(this.cachedLength),
  76. this.cachedRender = Array(this.cachedLength).fill(!1),
  77. this.cachedResolution = new Array(this.cachedLength),
  78. this.getPtr = 0,
  79. this.setPtr = 0,
  80. this.receiveIframes = 0,
  81. this.decodeIframes = 0,
  82. this.prevSenderTs = -1,
  83. this.serverSendTimeArray = new CircularArray(120,!1,[]),
  84. this.inPanoMode = !1,
  85. this.PanoStatus = {
  86. x: 0,
  87. y: 0,
  88. z: 0,
  89. tiles: []
  90. },
  91. this.DynamicPanoTest = !1,
  92. this.PanoMask = new ArrayBuffer(8),
  93. this.PanoView = new DataView(this.PanoMask),
  94. this.userId_test = "",
  95. this.PendingMasks = [],
  96. this.traceIdMap = new Map,
  97. this.responseTimeArray = [],
  98. this.processTimeArray = [],
  99. this.displayTimeArray = [],
  100. this.overallTimeArray = [],
  101. this.responseMiss = 0,
  102. this.processMiss = 0,
  103. this.displayMiss = 0,
  104. this.updateYUVCircular = new CircularArray(120,!1,[]),
  105. this.updateDropFrame = 0,
  106. this.metaParseAraay = [],
  107. this.responseMoveMiss = 0,
  108. this.processMoveMiss = 0,
  109. this.displayMoveMiss = 0,
  110. this.MovingTraceId = "",
  111. this.PendingMovingTraceId = "",
  112. this.inMovingMode = !1,
  113. this.StartMovingTs = 0,
  114. this.PendingStartMovingTs = 0,
  115. this.moveEvent = "",
  116. this.MoveToFrameCnt = 0,
  117. this.lastIsMoving = 0,
  118. this.MoveResponseDelay = 0,
  119. this.MoveProcessDelay = 0,
  120. this.MoveDisplayDelay = 0,
  121. this.lastMoveResponseTime = 0,
  122. this.lastMoveProcessTime = 0,
  123. this.lastMoveDisplayTime = 0,
  124. this.moveResponseCircular = new CircularArray(120,!0,[STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]),
  125. this.moveProcessCircular = new CircularArray(120,!0,[STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]),
  126. this.moveDisplayCircular = new CircularArray(120,!0,[STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]),
  127. this.moveStartPts = -1,
  128. this.frameServerCircular = new CircularArray(120,!1,[]),
  129. this.srvMetaIntervalCircular = new CircularArray(120,!1,[]),
  130. this.srvMediaIntervalCircular = new CircularArray(120,!1,[]),
  131. this.srvHBMetaIntervalCircular = new CircularArray(120,!1,[]),
  132. this.srvHBMetaIntervalSrvSentCircular = new CircularArray(120,!1,[]),
  133. this.frameClientCircular = new CircularArray(120,!1,[]),
  134. this.firstUpdateYUV = !0,
  135. this.functionMap = new Map,
  136. this.WASM_VERSION = "WASM-1.1",
  137. this.frameHistory = [],
  138. this.getVersion = function() {
  139. return DECODER_VERSION
  140. }
  141. ,
  142. this.downloadBlob = (r,n,o)=>{
  143. const a = new Blob([r],{
  144. type: o
  145. })
  146. , s = window.URL.createObjectURL(a);
  147. this.downloadURL(s, n),
  148. setTimeout(function() {
  149. return window.URL.revokeObjectURL(s)
  150. }, 1e3)
  151. }
  152. ,
  153. this.downloadURL = function(r, n) {
  154. const o = document.createElement("a");
  155. o.href = r,
  156. o.download = n,
  157. document.body.appendChild(o),
  158. o.style.display = "none",
  159. o.click(),
  160. o.remove()
  161. }
  162. ,
  163. this.Stringify = function(r) {
  164. let n = "";
  165. for (let a = 0; a < r.length / 8192; a++)
  166. n += String.fromCharCode.apply(null, r.slice(a * 8192, (a + 1) * 8192));
  167. return n
  168. }
  169. ,
  170. this._rtcp = e
  171. }
  172. registerLogger(e) {
  173. //defaultLogger = e
  174. }
  175. registerFunction(e, t) {
  176. this.functionMap.set(e, t)
  177. }
  178. hasFrmCntInCache(e) {
  179. let t = -1;
  180. for (let r = 0; r < this.cacheFrameComposes.length; r++)
  181. this.cacheFrameComposes[r].frameCnt == e && (t = r);
  182. return t
  183. }
  184. requestPanoramaTest(e, t, r, n, o) {
  185. const a = o
  186. , s = {
  187. action_type: 16,
  188. change_rotation_render_type_action: {
  189. render_type: 5,
  190. player: {
  191. position: {
  192. x: 0,
  193. y: 0,
  194. z: 0
  195. },
  196. angle: {
  197. yaw: 0,
  198. pitch: 0,
  199. roll: 0
  200. }
  201. },
  202. camera: {
  203. position: {
  204. x: e,
  205. y: t,
  206. z: r
  207. },
  208. angle: {
  209. yaw: 0,
  210. pitch: 0,
  211. roll: 0
  212. }
  213. },
  214. client_pano_titles_bitmap: n
  215. },
  216. trace_id: a,
  217. user_id: this.userId_test,
  218. packet_id: a
  219. };
  220. defaultLogger.debug("send data: ", s),
  221. this._rtcp.sendData(s)
  222. }
  223. onRotateInPanoMode(e) {
  224. const t = e.traceId
  225. , r = {};
  226. r.width = 1280,
  227. r.height = 720,
  228. r.horz_fov = 92,
  229. r.angle = {
  230. yaw: 100,
  231. pitch: 30
  232. };
  233. const n = new ArrayBuffer(8)
  234. , o = new DataView(n);
  235. getTilesInView(r, n);
  236. const a = n.slice(0);
  237. this.PendingMasks.unshift({
  238. buffer: a,
  239. angle: r.angle
  240. }),
  241. MaskSetToOne(18, this.PanoView),
  242. operateForDataView(o, this.PanoView, o, (s,l)=>s ^ s & l),
  243. this.requestPanoramaTest(0, 0, 0, [o.getUint8(0), o.getUint8(1), o.getUint8(2), o.getUint8(3), o.getUint8(4), o.getUint8(5), o.getUint8(6), o.getUint8(7)], t)
  244. }
  245. processMetaWithTraceId(e) {
  246. for (const t of e.traceIds) {
  247. if (this.traceIdMap.has(t)) {
  248. const r = this.traceIdMap.get(t);
  249. r != null && (r.receiveTime = Date.now(),
  250. r.status = 1)
  251. }
  252. if (t == this.PendingMovingTraceId) {
  253. this.inMovingMode = !0,
  254. this.MovingTraceId = this.PendingMovingTraceId,
  255. this.StartMovingTs = this.PendingStartMovingTs,
  256. this.PendingMovingTraceId = "",
  257. this.PendingStartMovingTs = 0,
  258. defaultLogger.info("MoveTo TraceId match", this.StartMovingTs, Date.now());
  259. const r = Date.now();
  260. this.lastMoveResponseTime = r,
  261. this.lastMoveProcessTime = r,
  262. this.lastMoveDisplayTime = r,
  263. this.frameServerCircular.clear(),
  264. this.frameClientCircular.clear()
  265. }
  266. }
  267. }
  268. onTraceId(e, t=this) {
  269. const r = e.traceId
  270. , n = e.timestamp
  271. , o = e.event;
  272. if (o === "Rotation") {
  273. const a = {
  274. traceId: r,
  275. pts: 0,
  276. startTime: n,
  277. receiveTime: 0,
  278. readyTime: 0,
  279. displayTime: 0,
  280. status: 0
  281. };
  282. this.traceIdMap.set(r, a);
  283. const s = setTimeout(()=>{
  284. if (s && clearTimeout(s),
  285. this.traceIdMap.has(r)) {
  286. const l = this.traceIdMap.get(r);
  287. switch (l == null ? void 0 : l.status) {
  288. case 0:
  289. {
  290. this.responseMiss += 1;
  291. break
  292. }
  293. case 1:
  294. {
  295. this.processMiss += 1;
  296. const u = l.receiveTime - l.startTime;
  297. this.responseTimeArray.push(u);
  298. break
  299. }
  300. case 2:
  301. {
  302. this.displayMiss += 1;
  303. const u = l.receiveTime - l.startTime
  304. , c = l.readyTime - l.receiveTime;
  305. this.responseTimeArray.push(u),
  306. this.processTimeArray.push(c);
  307. break
  308. }
  309. case 3:
  310. defaultLogger.debug("status is 3")
  311. }
  312. }
  313. }
  314. , 1e3)
  315. } else
  316. o === "MoveTo" ? (defaultLogger.info("receive moveto traceId ", r, " at timestamp", n),
  317. this.PendingMovingTraceId = r,
  318. this.PendingStartMovingTs = n,
  319. this.moveEvent = o,
  320. this.frameServerCircular.clear()) : o === "GetOnAirship" || o === "GetOnVehicle" ? (defaultLogger.info("receive airship traceId ", r, " at timestamp ", n),
  321. this.PendingMovingTraceId = r,
  322. this.PendingStartMovingTs = n,
  323. this.moveEvent = o,
  324. this.frameServerCircular.clear()) : (o === "GetOffAirship" || o === "GetOffVehicle") && this.clearMoveArray()
  325. }
  326. executeFunction(e, t) {
  327. if (this.functionMap.has(e)) {
  328. const r = this.functionMap.get(e);
  329. r != null && r(t)
  330. }
  331. }
  332. UpdateStats(e) {
  333. var t;
  334. (t = this._rtcp.connection) == null || t.getStats(null).then(r=>{
  335. r.forEach(n=>{
  336. n.type == "data-channel" && (this.rtcMessageReceived = n.messagesReceived - n.messagesSent,
  337. this.rtcBytesReceived = n.bytesReceived)
  338. }
  339. )
  340. }
  341. ),
  342. this.receivedMedia_worker = e.data.framesReceived,
  343. this.receivedYUV = e.data.framesDecoded,
  344. this.receivedEmit = e.data.framesRendered,
  345. this.mediaBytesReceived = e.data.mediaBytesReceived,
  346. this.metaBytesReceived = e.data.metaBytesReceived,
  347. this.packetsLost = e.data.packetsLost,
  348. this.packetsDrop = e.data.packetsDrop,
  349. this.framesAwait = e.data.framesAwait,
  350. this.decodeTimePerFrame = e.data.decodeTimePerFrame,
  351. this.decodeTimeMaxFrame = e.data.decodeTimeMaxFrame,
  352. this.returnFrames = e.data.framesReturned,
  353. this.sendOutBuffer = e.data.sendOutBuffer,
  354. this.DecodeJankTimes = e.data.JankTimes,
  355. this.bigDecodeJankTimes = e.data.bigJankTimes,
  356. this.receiveIframes = e.data.receivedIframe,
  357. this.decodeIframes = e.data.decodedIframe
  358. }
  359. ReceiveDecodeMessage(e) {
  360. var n;
  361. if (!this.firstYUVReceived) {
  362. this.firstYUVDecoded = e.data.yuv_ts;
  363. const o = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  364. defaultLogger.infoAndReportMeasurement({
  365. metric: "firstYUVDecodedAt",
  366. value: o,
  367. group: "joinRoom"
  368. }),
  369. this.firstRender = Date.now();
  370. const a = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  371. defaultLogger.infoAndReportMeasurement({
  372. metric: "firstRenderAt",
  373. value: a,
  374. group: "joinRoom"
  375. }),
  376. this.firstYUVReceived = !0,
  377. this.lastRenderTs = Date.now()
  378. }
  379. !this.cachedRender[this.setPtr] && this.cachedMetas[this.setPtr] != null && (this.cachedStreams[this.setPtr] != null && this.cachedStreams[this.setPtr].byteLength != 0 && (e.data.data == null ? (this.executeFunction("stream", {
  380. stream: this.cachedStreams[this.setPtr],
  381. width: this.cachedResolution[this.setPtr].width,
  382. height: this.cachedResolution[this.setPtr].height,
  383. pts: this.cachedPtss[this.setPtr]
  384. }),
  385. this.executeFunction("signal", {
  386. signal: this.cachedMetas[this.setPtr],
  387. pts: this.cachedPtss[this.setPtr],
  388. alreadyUpdateYUV: !0
  389. })) : this.updateDropFrame += 1,
  390. this.decoderWorker.postMessage({
  391. t: 2,
  392. frameCnt: this.cachedPtss[this.setPtr],
  393. buffer: this.cachedStreams[this.setPtr]
  394. }, [this.cachedStreams[this.setPtr].buffer])),
  395. this.getPtr = (this.getPtr + 1) % this.cachedLength);
  396. const t = e.data.metadata;
  397. if ((n = t == null ? void 0 : t.traceIds) != null && n.length) {
  398. for (const o of t.traceIds)
  399. if (this.traceIdMap.has(o)) {
  400. const a = this.traceIdMap.get(o);
  401. a != null && (a.readyTime = Date.now(),
  402. a.status = 2)
  403. }
  404. }
  405. if (e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs),
  406. this.userId_test = this.rtcp.network.room.userId,
  407. this.inMovingMode) {
  408. const o = Date.now()
  409. , a = o - this.lastMoveProcessTime;
  410. this.moveProcessCircular.add(a),
  411. this.lastMoveProcessTime = o
  412. }
  413. const r = this.setPtr;
  414. this.cachedStreams[r] = e.data.data,
  415. this.cachedMetas[r] = e.data.metadata,
  416. this.cachedPtss[r] = e.data.pts,
  417. this.cachedRender[r] = !1,
  418. this.cachedResolution[r] = {
  419. width: e.data.width,
  420. height: e.data.height
  421. },
  422. this.setPtr = (this.setPtr + 1) % this.cachedLength
  423. }
  424. SendCacheFrameInfo(e) {
  425. var h, f, d, _, g, m, v;
  426. const t = e.data.cachedKey
  427. , r = e.data.metadata
  428. , n = t
  429. , o = r
  430. , a = (d = (f = (h = o.newUserStates) == null ? void 0 : h.find(y=>y.userId === this.rtcp.network.room.userId)) == null ? void 0 : f.playerState) == null ? void 0 : d.roomTypeId
  431. , s = this.rtcp.network.room.skinId
  432. , l = (v = (m = (g = (_ = o.newUserStates) == null ? void 0 : _.find(y=>y.userId === this._rtcp.network.room.userId)) == null ? void 0 : g.playerState) == null ? void 0 : m.player) == null ? void 0 : v.position
  433. , u = {
  434. MsgType: 1,
  435. FrameCacheMsg: {
  436. FrameIndex: n,
  437. RoomTypeId: a,
  438. SkinID: s,
  439. Position: l
  440. }
  441. };
  442. let c = "";
  443. try {
  444. c = JSON.stringify(u)
  445. } catch (y) {
  446. defaultLogger.error(y);
  447. return
  448. }
  449. }
  450. ReceivePanoramaDecodeMessage(e) {
  451. defaultLogger.info("Receive Panorama Image in Workers.ts"),
  452. MaskSetToOne(e.data.tileId, this.PanoView);
  453. let t = 0, r;
  454. const n = this.PendingMasks.length;
  455. for (t = 0; t < n; t++) {
  456. const o = this.PendingMasks[t].buffer
  457. , a = new DataView(o)
  458. , s = new ArrayBuffer(8)
  459. , l = new DataView(s);
  460. if (operateForDataView(this.PanoView, a, l, (u,c)=>c ^ u & c),
  461. IsAll0(l)) {
  462. r = this.PendingMasks[t].angle;
  463. break
  464. }
  465. }
  466. for (let o = t; o < n; o++)
  467. this.PendingMasks.pop();
  468. this.executeFunction("panorama", {
  469. data: e.data.data,
  470. tileId: e.data.tileId,
  471. pos: {
  472. x: e.data.x,
  473. y: e.data.y,
  474. z: e.data.z
  475. },
  476. uuid: e.data.uuid,
  477. finished: !0,
  478. matchAngle: r
  479. })
  480. }
  481. enable_decoder_queue_logging() {
  482. this.decoderWorker.postMessage({
  483. t: 100,
  484. status: !0
  485. })
  486. }
  487. disable_decoder_queue_logging() {
  488. this.decoderWorker.postMessage({
  489. t: 100,
  490. status: !1
  491. })
  492. }
  493. async init(e={
  494. width: 1280,
  495. height: 720
  496. }) {
  497. for (let r = 0; r < FRAME_COMPOSE_LENGTH; r++) {
  498. const n = {
  499. buffer: new Uint8Array(2621440),
  500. size: 0,
  501. startReceiveTime: 0,
  502. serverTime: 0,
  503. frameCnt: -1
  504. };
  505. this.cacheFrameComposes.push(n)
  506. }
  507. const t = new Blob([decoder],{
  508. type: "application/javascript"
  509. });
  510. this.decoderWorker = new Worker(URL.createObjectURL(t));
  511. this.decoderWorker.postMessage({
  512. t: 9,
  513. url: WASM_URLS[WASM_Version],
  514. jitterLength: DECODER_PASSIVE_JITTER
  515. });
  516. this.decoderWorker.postMessage({
  517. t: 1,
  518. config: e
  519. });
  520. return new Promise(r=>{
  521. this.decoderWorker.onmessage = n=>{
  522. switch (n.data.t) {
  523. case 0:
  524. this.ReceiveDecodeMessage(n);
  525. break;
  526. case 1:
  527. this.UpdateStats(n);
  528. break;
  529. case 2:
  530. r();
  531. break;
  532. case 3:
  533. this.SendCacheFrameInfo(n);
  534. break;
  535. case 4:
  536. {
  537. const o = new Date().toISOString()
  538. , a = USER_ID + "-" + PAGE_SESSION + "-" + SERVER_SESSION + "-" + o + ".264";
  539. uploadStream(COS_PREFIX + a, n.data.fileObj);
  540. break
  541. }
  542. case 5:
  543. this.executeFunction("signal", {
  544. signal: n.data.metadata,
  545. pts: -1,
  546. alreadyUpdateYUV: !1
  547. });
  548. break;
  549. case 6:
  550. defaultLogger.infoAndReportMeasurement(n.data),
  551. defaultLogger.debug("WASM Ready Cost");
  552. break;
  553. case 7:
  554. this.ReceivePanoramaDecodeMessage(n);
  555. break;
  556. case 8:
  557. {
  558. const o = {
  559. MstType: 0
  560. };
  561. let a = "";
  562. try {
  563. a = JSON.stringify(o)
  564. } catch (l) {
  565. defaultLogger.error(l);
  566. return
  567. }
  568. const s = "wasm:" + a;
  569. this._rtcp.sendStringData(s);
  570. break
  571. }
  572. case 9:
  573. {
  574. defaultLogger.info(n.data.printMsg);
  575. break
  576. }
  577. case 10:
  578. {
  579. defaultLogger.error(n.data.printMsg),
  580. this.executeFunction("error", {
  581. code: n.data.code,
  582. message: n.data.printMsg
  583. });
  584. break
  585. }
  586. default:
  587. defaultLogger.error("Receive unknown message event from decoder"),
  588. defaultLogger.debug(n.data);
  589. break
  590. }
  591. }
  592. }
  593. )
  594. }
  595. UpdateYUV() {
  596. var t, r;
  597. const e = this.getPtr;
  598. if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
  599. const n = Date.now();
  600. if (this.firstUpdateYUV) {
  601. const h = ((t = this.cachedStreams[e]) == null ? void 0 : t.byteLength) || 0;
  602. defaultLogger.infoAndReportMeasurement({
  603. metric: "firstUpdateStreamLength",
  604. value: h,
  605. group: "joinRoom"
  606. }),
  607. this.firstUpdateYUV = !1
  608. }
  609. this.cachedStreams[e] != null && this.executeFunction("stream", {
  610. stream: this.cachedStreams[e],
  611. width: this.cachedResolution[e].width,
  612. height: this.cachedResolution[e].height,
  613. pts: this.cachedPtss[e]
  614. });
  615. const o = Date.now();
  616. this.cachedStreams[e] != null && this.decoderWorker.postMessage({
  617. t: 2,
  618. frameCnt: this.cachedPtss[e],
  619. buffer: this.cachedStreams[e]
  620. }, [this.cachedStreams[e].buffer]);
  621. const a = Date.now()
  622. , s = o - n
  623. , l = a - o;
  624. (s > 33 || l > 10) && defaultLogger.debug("[wwwarning] updateYUV takes ", s, " ms, postMessage takes ", l, " ms for index ", this.cachedPtss[e]),
  625. o - this.lastRenderTs > 84 && this.JankTimes++,
  626. o - this.lastRenderTs > 125 && this.bigJankTimes++,
  627. this.lastRenderTs = o;
  628. const u = o - n;
  629. this.updateYUVCircular.add(u);
  630. const c = this.cachedMetas[e];
  631. if ((r = c == null ? void 0 : c.traceIds) != null && r.length) {
  632. for (const h of c.traceIds)
  633. if (this.traceIdMap.has(h)) {
  634. const f = this.traceIdMap.get(h);
  635. if (f != null) {
  636. f.displayTime = Date.now(),
  637. f.status = 3;
  638. const d = f.receiveTime - f.startTime
  639. , _ = f.readyTime - f.receiveTime
  640. , g = f.displayTime - f.readyTime
  641. , m = f.displayTime - f.startTime;
  642. this.responseTimeArray.push(d),
  643. this.processTimeArray.push(_),
  644. this.displayTimeArray.push(g),
  645. this.overallTimeArray.push(m),
  646. this.traceIdMap.delete(h)
  647. }
  648. }
  649. }
  650. if (this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs),
  651. this.inMovingMode) {
  652. const h = Date.now()
  653. , f = h - this.lastMoveDisplayTime;
  654. this.moveDisplayCircular.add(f),
  655. this.lastMoveDisplayTime = h
  656. }
  657. this.executeFunction("signal", {
  658. signal: this.cachedMetas[e],
  659. pts: this.cachedPtss[e],
  660. alreadyUpdateYUV: !0
  661. }),
  662. this.cachedRender[e] = !0,
  663. this.getPtr = (this.getPtr + 1) % this.cachedLength
  664. }
  665. }
  666. unmarshalPano(e) {
  667. const t = new DataView(e);
  668. if (t.getUint32(0) != 1723558763)
  669. return !1;
  670. console.log("Receive Pano Message"),
  671. t.getUint16(4);
  672. const n = t.getUint16(6)
  673. , o = t.getUint32(8)
  674. , a = t.getUint32(12) - (1 << 30) * 2
  675. , s = t.getUint32(16) - (1 << 30) * 2
  676. , l = t.getUint32(20) - (1 << 30) * 2
  677. , u = t.getUint32(24)
  678. , c = new Uint8Array(e).subarray(28, 64)
  679. , h = String.fromCharCode.apply(null, c)
  680. , f = t.getUint32(64)
  681. , d = e.byteLength - n;
  682. if (d == u) {
  683. const g = {
  684. data: new Uint8Array(e).subarray(n),
  685. mediaLen: u,
  686. tileId: o,
  687. uuid: h,
  688. x: a,
  689. y: s,
  690. z: l
  691. };
  692. this.decoderWorker.postMessage({
  693. t: 8,
  694. data: g
  695. })
  696. } else {
  697. const _ = new Uint8Array(e,n,d);
  698. if (this.cachePanoTileID == o) {
  699. if (this.panoCacheBuffer.set(_, f),
  700. this.panoCacheSize += d,
  701. this.panoCacheSize === u) {
  702. const m = {
  703. data: new Uint8Array(this.panoCacheBuffer).slice(0, u),
  704. mediaLen: u,
  705. tileId: o,
  706. uuid: h,
  707. x: a,
  708. y: s,
  709. z: l
  710. };
  711. this.decoderWorker.postMessage({
  712. t: 8,
  713. data: m
  714. }),
  715. this.panoCacheSize = 0
  716. }
  717. } else
  718. this.panoCacheBuffer.set(_, f),
  719. this.panoCacheSize = d,
  720. this.cachePanoTileID = o
  721. }
  722. return !0
  723. }
  724. clearMoveArray() {
  725. this.MovingTraceId = "",
  726. this.inMovingMode = !1,
  727. this.StartMovingTs = 0,
  728. this.MoveToFrameCnt = 0,
  729. this.MoveResponseDelay = 0,
  730. this.MoveProcessDelay = 0,
  731. this.MoveDisplayDelay = 0,
  732. this.moveStartPts = -1,
  733. this.moveResponseCircular.clear(),
  734. this.moveProcessCircular.clear(),
  735. this.moveDisplayCircular.clear(),
  736. this.moveEvent = ""
  737. }
  738. getIsMoving(e) {
  739. let t;
  740. if (typeof e.newUserStates != "undefined")
  741. for (let r = 0; r < e.newUserStates.length; r++) {
  742. const n = e.newUserStates[r];
  743. if (n.userId == this.rtcp.network.room.userId) {
  744. t = n.renderInfo.isMoving;
  745. break
  746. }
  747. }
  748. return t
  749. }
  750. isHeartBeatPacket(e, t) {
  751. return new DataView(e).getUint32(0) == 2009889916
  752. }
  753. resetSendTimeDiff() {
  754. this.prevSenderTs = 0,
  755. this.serverSendTimeArray.clear()
  756. }
  757. calcSendTimeDiff(e) {
  758. if (this.prevSenderTs == -1) {
  759. this.prevSenderTs = e;
  760. return
  761. }
  762. const t = e - this.prevSenderTs;
  763. this.serverSendTimeArray.add(t),
  764. this.prevSenderTs = e
  765. }
  766. unmarshalStream(e) {
  767. var T, C, A, S, P, R, M, x, I, w;
  768. const t = new DataView(e);
  769. if (t.getUint32(0) != 1437227610)
  770. return !1;
  771. t.getUint16(4);
  772. const n = t.getUint16(6)
  773. , o = t.getUint16(8)
  774. , a = o
  775. , s = t.getUint16(10);
  776. let l = !1;
  777. s == 1 && (l = !0);
  778. const u = t.getUint32(12)
  779. , c = t.getUint32(16)
  780. , h = t.getUint32(20)
  781. , f = t.getUint16(24)
  782. , d = t.getUint16(26)
  783. , _ = t.getUint32(28)
  784. , g = t.getUint32(n - 4)
  785. , m = u + c
  786. , v = e.byteLength - n
  787. , y = new Uint8Array(e,n,v);
  788. this.calcSendTimeDiff(h);
  789. let b;
  790. if (this.inPanoMode && (c > 0 || f))
  791. return defaultLogger.error("Stream Protocal Violation: receive illegal stream in Pano mode"),
  792. !0;
  793. if (v === m) {
  794. this.receivedMedia++;
  795. const O = new Uint8Array(e).subarray(n);
  796. h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
  797. const D = Date.now();
  798. D - this.lastClientTS > 60 ? this.clientFrameSlow++ : D - this.lastClientTS < 16 && this.clientFrameFast++;
  799. const F = c === 0
  800. , V = h - this.lastServerTS;
  801. this.lastServerTS != 0 && ((o + 65536 - this.lastSeq) % 65536 === 1 && this.lastIsPureMeta == F && (F ? this.srvMetaIntervalCircular.add(V) : this.srvMediaIntervalCircular.add(V)),
  802. this.frameServerCircular.add(V),
  803. this.frameClientCircular.add(D - this.lastClientTS)),
  804. this.lastSeq = o,
  805. this.lastIsPureMeta = F,
  806. this.lastServerTS = h,
  807. this.lastClientTS = D;
  808. const N = O.subarray(0, u)
  809. , L = Date.now()
  810. , k = JSON.parse(this.Stringify(N))
  811. , U = Date.now();
  812. this.showAllReceivedMetadata && console.log(h, D, k),
  813. this.metaParseAraay.push(U - L),
  814. (T = k.traceIds) != null && T.length && this.processMetaWithTraceId(k),
  815. c != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = o),
  816. this.moveStartPts == o && (this.MoveResponseDelay = Date.now() - this.StartMovingTs,
  817. console.log("move response delay: ", o, this.moveStartPts, this.MoveResponseDelay));
  818. const z = this.getIsMoving(k);
  819. if (this.inMovingMode && z == 0 && this.lastIsMoving == 1 && this.clearMoveArray(),
  820. typeof z != "undefined" && (this.lastIsMoving = z),
  821. this.inMovingMode) {
  822. const G = Date.now()
  823. , W = G - this.lastMoveResponseTime;
  824. this.moveResponseCircular.add(W),
  825. this.lastMoveResponseTime = G
  826. }
  827. (f || d) && (b = (P = (S = (A = (C = k.newUserStates) == null ? void 0 : C.find(G=>G.userId === this._rtcp.network.room.userId)) == null ? void 0 : A.playerState) == null ? void 0 : S.player) == null ? void 0 : P.position);
  828. const H = {
  829. t: 0,
  830. data: O,
  831. mediaLen: c,
  832. metaLen: u,
  833. metadata: k,
  834. frameCnt: a,
  835. server_ts: h,
  836. isIDR: l,
  837. cacheRequest: d,
  838. cached: f,
  839. cachedKey: _,
  840. position: b
  841. };
  842. if (this.inPanoMode)
  843. return this.executeFunction("signal", {
  844. signal: k,
  845. pts: -1,
  846. alreadyUpdateYUV: !0
  847. }),
  848. !0;
  849. if (this.decoderWorker.postMessage(H, [O.buffer]),
  850. !this.firstMediaReceived) {
  851. this.firstMediaArraval = Date.now();
  852. const G = this.firstMediaArraval - this.rtcp.network.room._startTime;
  853. defaultLogger.infoAndReportMeasurement({
  854. metric: "firstMediaArravalAt",
  855. value: G,
  856. group: "joinRoom"
  857. }),
  858. this.firstMediaReceived = !0
  859. }
  860. } else {
  861. const O = this.hasFrmCntInCache(a);
  862. if (O != -1)
  863. if (this.cacheFrameComposes[O].buffer.set(y, g),
  864. this.cacheFrameComposes[O].size += v,
  865. this.cacheFrameComposes[O].size === m) {
  866. const D = new Uint8Array(this.cacheFrameComposes[O].buffer).slice(0, m);
  867. this.cacheFrameComposes[O].frameCnt = -1,
  868. this.cacheFrameComposes[O].size = 0,
  869. this.cacheFrameComposes[O].startReceiveTime = 0,
  870. this.cacheFrameComposes[O].serverTime = 0,
  871. this.receivedMedia++,
  872. h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
  873. const F = Date.now();
  874. F - this.lastClientTS > 60 ? this.clientFrameSlow++ : F - this.lastClientTS < 16 && this.clientFrameFast++,
  875. this.lastServerTS != 0 && (this.frameServerCircular.add(h - this.lastServerTS),
  876. this.frameClientCircular.add(F - this.lastClientTS)),
  877. this.lastServerTS = h,
  878. this.lastClientTS = F;
  879. const V = D.subarray(0, u)
  880. , N = Date.now()
  881. , L = JSON.parse(this.Stringify(V))
  882. , k = Date.now();
  883. this.showAllReceivedMetadata && console.log(h, F, L),
  884. this.metaParseAraay.push(k - N),
  885. (R = L.traceIds) != null && R.length && this.processMetaWithTraceId(L),
  886. c != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = o),
  887. this.moveStartPts == o && (this.MoveResponseDelay = Date.now() - this.StartMovingTs);
  888. const U = this.getIsMoving(L);
  889. if (this.inMovingMode && U == 0 && this.lastIsMoving == 1 && this.clearMoveArray(),
  890. typeof U != "undefined" && (this.lastIsMoving = U),
  891. this.inMovingMode) {
  892. const H = Date.now()
  893. , G = H - this.lastMoveResponseTime;
  894. this.moveResponseCircular.add(G),
  895. this.lastMoveResponseTime = H
  896. }
  897. (f || d) && (b = (w = (I = (x = (M = L.newUserStates) == null ? void 0 : M.find(H=>H.userId === this._rtcp.network.room.userId)) == null ? void 0 : x.playerState) == null ? void 0 : I.player) == null ? void 0 : w.position);
  898. const z = {
  899. t: 0,
  900. data: D,
  901. mediaLen: c,
  902. metaLen: u,
  903. metadata: L,
  904. frameCnt: a,
  905. server_ts: h,
  906. isIDR: l,
  907. cacheRequest: d,
  908. cached: f,
  909. cachedKey: _,
  910. position: b
  911. };
  912. if (this.inPanoMode)
  913. return this.executeFunction("signal", {
  914. signal: L,
  915. pts: -1,
  916. alreadyUpdateYUV: !0
  917. }),
  918. !0;
  919. if (this.decoderWorker.postMessage(z, [D.buffer]),
  920. !this.firstMediaReceived) {
  921. this.firstMediaArraval = Date.now();
  922. const H = this.firstMediaArraval - this.rtcp.network.room._startTime;
  923. defaultLogger.infoAndReportMeasurement({
  924. metric: "firstMediaArravalAt",
  925. value: H,
  926. group: "joinRoom"
  927. }),
  928. this.firstMediaReceived = !0
  929. }
  930. } else
  931. this.cacheFrameComposes[O].size > m && defaultLogger.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", m);
  932. else if (O == -1) {
  933. let D = this.hasFrmCntInCache(-1);
  934. if (D == -1) {
  935. let F = Date.now() + 1e18
  936. , V = -1;
  937. for (let N = 0; N < this.cacheFrameComposes.length; N++)
  938. this.cacheFrameComposes[N].serverTime < F && (F = this.cacheFrameComposes[N].serverTime,
  939. V = N);
  940. D = V
  941. }
  942. this.cacheFrameComposes[D].buffer.set(y, g),
  943. this.cacheFrameComposes[D].size = v,
  944. this.cacheFrameComposes[D].frameCnt = a,
  945. this.cacheFrameComposes[D].startReceiveTime = Date.now(),
  946. this.cacheFrameComposes[D].serverTime = h
  947. }
  948. }
  949. return !0
  950. }
  951. reset() {
  952. defaultLogger.debug("Worker reset is called"),
  953. this.cacheFrameCnt = 0,
  954. this.receivedMedia = 0,
  955. this.reconnectSignal = !0,
  956. this.decoderWorker.postMessage({
  957. t: 4
  958. })
  959. }
  960. dataHandleOff(e) {
  961. defaultLogger.debug("hhh")
  962. }
  963. dataHandle(e) {
  964. this.saveframe && (this.decoderWorker.postMessage({
  965. t: 6
  966. }),
  967. this.saveframe = !1),
  968. this.SaveMediaStream && (this.decoderWorker.postMessage({
  969. t: 7
  970. }),
  971. this.SaveMediaStream = !1);
  972. const t = new Uint8Array(e);
  973. if (t.length >= 4 && this.isHeartBeatPacket(t.buffer, t.length) == !0)
  974. return;
  975. if (t.length > 36 && this.unmarshalStream(t.buffer) == !0) {
  976. this.reconnectSignal && (this.executeFunction("reconnectedFrame", {}),
  977. this.reconnectSignal = !1);
  978. return
  979. }
  980. if (t.length > 20 && this.unmarshalPano(t.buffer) == !0)
  981. return;
  982. this.noWasmBytesReceived += e.byteLength;
  983. const r = JSON.parse(this.Stringify(t));
  984. this.executeFunction("signal", {
  985. signal: r,
  986. pts: -1,
  987. alreadyUpdateYUV: !0
  988. })
  989. }
  990. changePanoMode(e) {
  991. this.inPanoMode = e
  992. }
  993. uploadDataToServer() {
  994. this.DynamicPanoTest == !0 && (this.onRotateInPanoMode({
  995. traceId: "b2e1a296-6438-4371-8a31-687beb724ebe"
  996. }),
  997. this.DynamicPanoTest = !1);
  998. function e(ie, ee) {
  999. return ee == -1 && (ee = 0),
  1000. ie + ee
  1001. }
  1002. function t(ie, ee) {
  1003. return Math.max(ie, ee)
  1004. }
  1005. const r = this.responseTimeArray.reduce(e, 0) / this.responseTimeArray.length || 0
  1006. , n = this.processTimeArray.reduce(e, 0) / this.processTimeArray.length || 0
  1007. , o = this.displayTimeArray.reduce(e, 0) / this.displayTimeArray.length || 0
  1008. , a = this.overallTimeArray.reduce(e, 0) / this.overallTimeArray.length || 0
  1009. , s = this.overallTimeArray.length;
  1010. this.responseTimeArray = [],
  1011. this.processTimeArray = [],
  1012. this.displayTimeArray = [],
  1013. this.overallTimeArray = [];
  1014. const l = this.moveResponseCircular.getThreshPercent()
  1015. , u = l[0]
  1016. , c = l[1]
  1017. , h = l[2]
  1018. , f = l[3]
  1019. , d = l[4]
  1020. , _ = d - f
  1021. , g = 1 - c / d || 0
  1022. , m = [u, c - u, h - c, f - h, _]
  1023. , v = this.moveProcessCircular.getThreshPercent()
  1024. , y = v[0]
  1025. , b = v[1]
  1026. , T = v[2]
  1027. , C = v[3]
  1028. , A = v[4]
  1029. , S = A - C
  1030. , P = 1 - b / A || 0
  1031. , R = [y, b - y, T - b, C - T, S]
  1032. , M = this.moveDisplayCircular.getThreshPercent()
  1033. , x = M[0]
  1034. , I = M[1]
  1035. , w = M[2]
  1036. , O = M[3]
  1037. , D = M[4]
  1038. , F = D - O
  1039. , V = 1 - I / D || 0
  1040. , N = [x, I - x, w - I, O - w, F]
  1041. , L = x
  1042. , k = I - x
  1043. , U = w - I
  1044. , z = O - w
  1045. , H = F
  1046. , G = this.moveResponseCircular.getAvg()
  1047. , W = this.moveProcessCircular.getAvg()
  1048. , j = this.moveDisplayCircular.getAvg()
  1049. , B = this.moveResponseCircular.getMax()
  1050. , X = this.moveProcessCircular.getMax()
  1051. , $ = this.moveDisplayCircular.getMax()
  1052. , Y = this.moveResponseCircular.getStandardDeviation()
  1053. , K = this.moveProcessCircular.getStandardDeviation()
  1054. , Z = this.moveDisplayCircular.getStandardDeviation();
  1055. this.moveResponseCircular.getIncomingAvg(),
  1056. this.moveProcessCircular.getIncomingAvg(),
  1057. this.moveDisplayCircular.getIncomingAvg(),
  1058. this.moveResponseCircular.getIncomingMax(),
  1059. this.moveProcessCircular.getIncomingMax(),
  1060. this.moveDisplayCircular.getIncomingMax(),
  1061. this.moveResponseCircular.clearIncoming(),
  1062. this.moveProcessCircular.clearIncoming(),
  1063. this.moveDisplayCircular.clearIncoming();
  1064. const q = this.frameServerCircular.getAvg()
  1065. , J = this.frameServerCircular.getMax();
  1066. this.frameClientCircular.getAvg(),
  1067. this.frameClientCircular.getMax();
  1068. const Q = this.metaParseAraay.reduce(e, 0) / this.metaParseAraay.length || 0
  1069. , te = this.metaParseAraay.reduce(t, 0);
  1070. this.metaParseAraay = [];
  1071. const re = {
  1072. mediaBytesReceived: this.mediaBytesReceived,
  1073. metaBytesReceived: this.metaBytesReceived,
  1074. packetsLost: this.packetsLost,
  1075. timestamp: Date.now(),
  1076. frameHeight: 1280,
  1077. frameWidth: 720,
  1078. framesReceived: this.receivedMedia,
  1079. framesReceivedWorker: this.receivedMedia_worker,
  1080. framesDecoded: this.receivedYUV,
  1081. framesEmited: this.receivedEmit,
  1082. decodeTimePerFrame: this.decodeTimePerFrame,
  1083. decodeTimeMaxFrame: this.decodeTimeMaxFrame,
  1084. packetsDrop: this.packetsDrop,
  1085. framesAwait: this.framesAwait,
  1086. firstMediaArraval: this.firstMediaArraval,
  1087. firstYUVDecoded: this.firstYUVDecoded,
  1088. firstRender: this.firstRender,
  1089. returnFrames: this.returnFrames,
  1090. sendOutBuffer: this.sendOutBuffer,
  1091. maxGraphicTime: this.updateYUVCircular.getMax(),
  1092. averageGraphicTime: this.updateYUVCircular.getAvg(),
  1093. jankTimes: this.JankTimes,
  1094. bigJankTimes: this.bigJankTimes,
  1095. decodeJankTimes: this.DecodeJankTimes,
  1096. bigDecodeJankTimes: this.bigDecodeJankTimes,
  1097. serverFrameSlow: this.serverFrameSlow,
  1098. serverFrameFast: this.serverFrameFast,
  1099. clientFrameSlow: this.clientFrameSlow,
  1100. clientFrameFast: this.clientFrameFast,
  1101. rtcMessageReceived: this.rtcMessageReceived,
  1102. rtcBytesReceived: this.rtcBytesReceived - this.noWasmBytesReceived,
  1103. receiveIframes: this.receiveIframes,
  1104. decodeIframes: this.decodeIframes,
  1105. avgResponseTime: r,
  1106. avgProcessTime: n,
  1107. avgDisplayTime: o,
  1108. avgOverallTime: a,
  1109. overallTimeCount: s,
  1110. responseMiss: this.responseMiss,
  1111. processMiss: this.processMiss,
  1112. displayMiss: this.displayMiss,
  1113. updateDropFrame: this.updateDropFrame,
  1114. moveEvent: this.moveEvent,
  1115. avgResponseMoveDiff: this.moveEvent == "MoveTo" ? G : 0,
  1116. avgProcessMoveDiff: this.moveEvent == "MoveTo" ? W : 0,
  1117. avgDisplayMoveDiff: this.moveEvent == "MoveTo" ? j : 0,
  1118. maxResponseMoveDiff: this.moveEvent == "MoveTo" ? B : 0,
  1119. maxProcessMoveDiff: this.moveEvent == "MoveTo" ? X : 0,
  1120. maxDisplayMoveDiff: this.moveEvent == "MoveTo" ? $ : 0,
  1121. moveResponseJank: this.moveEvent == "MoveTo" ? g : 0,
  1122. moveProcessJank: this.moveEvent == "MoveTo" ? P : 0,
  1123. moveDisplayJank: this.moveEvent == "MoveTo" ? V : 0,
  1124. moveResponseCounts: this.moveEvent == "MoveTo" ? m.toString() : "0,0,0,0,0",
  1125. moveProcessCounts: this.moveEvent == "MoveTo" ? R.toString() : "0,0,0,0,0",
  1126. moveDisplayCounts: this.moveEvent == "MoveTo" ? N.toString() : "0,0,0,0,0",
  1127. MoveDisplayCountGood: this.moveEvent == "MoveTo" ? L.toString() : "0",
  1128. MoveDisplayCountWell: this.moveEvent == "MoveTo" ? k.toString() : "0",
  1129. MoveDisplayCountFair: this.moveEvent == "MoveTo" ? U.toString() : "0",
  1130. MoveDisplayCountBad: this.moveEvent == "MoveTo" ? z.toString() : "0",
  1131. MoveDisplayCountRest: this.moveEvent == "MoveTo" ? H.toString() : "0",
  1132. moveResponseDelay: this.moveEvent == "MoveTo" ? this.MoveResponseDelay : 0,
  1133. moveProcessDelay: this.moveEvent == "MoveTo" ? this.MoveProcessDelay : 0,
  1134. moveDisplayDelay: this.moveEvent == "MoveTo" ? this.MoveDisplayDelay : 0,
  1135. sdMoveResponseLongTime: Y,
  1136. sdMoveProcessLongTime: K,
  1137. sdMoveDisplayLongTime: Z,
  1138. avgResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? G : 0,
  1139. avgProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? W : 0,
  1140. avgDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? j : 0,
  1141. maxResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? B : 0,
  1142. maxProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? X : 0,
  1143. maxDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? $ : 0,
  1144. flyResponseJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? g : 0,
  1145. flyProcessJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? P : 0,
  1146. flyDisplayJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? V : 0,
  1147. flyResponseCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? m.toString() : "0,0,0,0,0",
  1148. flyProcessCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? R.toString() : "0,0,0,0,0",
  1149. flyDisplayCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? N.toString() : "0,0,0,0,0",
  1150. flyResponseDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveResponseDelay : 0,
  1151. flyProcessDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveProcessDelay : 0,
  1152. flyDisplayDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveDisplayDelay : 0,
  1153. avgMetaParseTime: Q,
  1154. maxMetaParseTime: te,
  1155. avgServerDiff: q,
  1156. maxServerDiff: J,
  1157. streamType: WASM_Version
  1158. };
  1159. return this.lastReturnFrames = this.returnFrames,
  1160. this.lastReceivedEmit = this.receivedEmit,
  1161. re
  1162. }
  1163. }