Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ coverage:
project:
default:
threshold: 1%
patch:
patch: off
default:
threshold: 1%
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
"dependencies": {
"@actions/core": "^1.10.0",
"@dcl/protocol": "1.0.0-15561894653.commit-9a42a0f",
"@dcl/protocol": "1.0.0-16079712278.commit-7b0267f",
"@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1",
"@dcl/ts-proto": "1.153.0",
"@types/fs-extra": "^9.0.12",
Expand Down
26 changes: 21 additions & 5 deletions packages/@dcl/ecs/src/systems/crdt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import {
import { INetowrkEntityType } from '../../components/types'
import * as networkUtils from '../../serialization/crdt/network/utils'

// NetworkMessages can only have a MAX_SIZE of 12kb. So we need to send it in chunks.
export const LIVEKIT_MAX_SIZE = 12

/**
* @public
*/
Expand Down Expand Up @@ -245,8 +248,6 @@ export function crdtSceneSystem(engine: PreEngine, onProcessEntityComponentChang
// Send CRDT messages to transports
const transportBuffer = new ReadWriteByteBuffer()
for (const index in transports) {
// NetworkMessages can only have a MAX_SIZE of 13kb. So we need to send it in chunks.
const LIVEKIT_MAX_SIZE = 13
const __NetworkMessagesBuffer: Uint8Array[] = []

const transportIndex = Number(index)
Expand All @@ -260,10 +261,25 @@ export function crdtSceneSystem(engine: PreEngine, onProcessEntityComponentChang

// Then we send all the new crdtMessages that the transport needs to process
for (const message of crdtMessages) {
if (isNetworkTransport && transportBuffer.toBinary().byteLength / 1024 > LIVEKIT_MAX_SIZE) {
__NetworkMessagesBuffer.push(transportBuffer.toBinary())
transportBuffer.resetBuffer()
// Check if adding this message would exceed the size limit
const currentBufferSize = transportBuffer.toBinary().byteLength
const messageSize = message.messageBuffer.byteLength

if (isNetworkTransport && (currentBufferSize + messageSize) / 1024 > LIVEKIT_MAX_SIZE) {
// If the current buffer has content, save it as a chunk
if (currentBufferSize > 0) {
__NetworkMessagesBuffer.push(transportBuffer.toCopiedBinary())
transportBuffer.resetBuffer()
}

// If the message itself is larger than the limit, we need to handle it specially
// For now, we'll skip it to prevent infinite loops
if (messageSize / 1024 > LIVEKIT_MAX_SIZE) {
console.error(`Message too large (${messageSize} bytes), skipping message for entity ${message.entityId}`)
continue
}
}

// Avoid echo messages
if (message.transportId === transportIndex) continue

Expand Down
87 changes: 47 additions & 40 deletions packages/@dcl/inspector/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/@dcl/inspector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@dcl/inspector",
"version": "0.1.0",
"dependencies": {
"@dcl/asset-packs": "2.4.3",
"@dcl/asset-packs": "2.5.1",
"ts-deepmerge": "^7.0.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AiFillSound } from 'react-icons/ai'
import { IoVideocamOutline } from 'react-icons/io5'
import { FaFile } from 'react-icons/fa'

import { toWearableWithBlobs } from './utils'
import { toEmoteWithBlobs, toWearableWithBlobs } from './utils'
import { Props } from './types'

import './AssetPreview.css'
Expand All @@ -15,13 +15,21 @@ import { useRef } from 'react'
const WIDTH = 300
const HEIGHT = 300

export function AssetPreview({ value, resources, onScreenshot, onLoad }: Props) {
export function AssetPreview({ value, resources, onScreenshot, onLoad, isEmote }: Props) {
const preview = useMemo(() => {
const ext = value.name.split('.').pop()
switch (ext) {
case 'gltf':
case 'glb':
return <GltfPreview value={value} resources={resources} onScreenshot={onScreenshot} onLoad={onLoad} />
return (
<GltfPreview
value={value}
resources={resources}
onScreenshot={onScreenshot}
onLoad={onLoad}
isEmote={isEmote}
/>
)
case 'png':
case 'jpg':
case 'jpeg':
Expand All @@ -40,27 +48,52 @@ export function AssetPreview({ value, resources, onScreenshot, onLoad }: Props)
return <div className="AssetPreview">{preview}</div>
}

function GltfPreview({ value, resources, onScreenshot, onLoad }: Props) {
function GltfPreview({ value, resources, onScreenshot, onLoad, isEmote }: Props) {
const [loading, setLoading] = useState(true)
const handleLoad = useCallback(() => {
onLoad?.()
const wp = WearablePreview.createController(value.name)
void wp.scene.getScreenshot(WIDTH, HEIGHT).then(($) => {

const handleScreenshot = useCallback(
(screenshot: string) => {
setTimeout(() => {
onScreenshot($)
onScreenshot(screenshot)
setLoading(false)
}, 1000) // ugly hack to avoid iframe flickering...
})
}, [onLoad])
}, 1000)
},
[onScreenshot]
)

const handleLoad = useCallback(async () => {
onLoad?.()
const wp = WearablePreview.createController(value.name)
if (isEmote) {
const length = await wp.emote.getLength()
//takes a screenshot at the middle of the emote
void wp.emote.goTo(length * 0.5).then(() => {
void wp.scene.getScreenshot(WIDTH, HEIGHT).then(handleScreenshot)
})
} else {
void wp.scene.getScreenshot(WIDTH, HEIGHT).then(handleScreenshot)
}
}, [onLoad, value, isEmote, handleScreenshot])

const wearablePreviewExtraOptions = isEmote
? {
profile: 'default',
disableFace: true,
disableDefaultWearables: true,
skin: '000000',
wheelZoom: 2
}
: {}

return (
<>
<div className={cx('GltfPreview', { hidden: loading })}>
<WearablePreview
id={value.name}
blob={toWearableWithBlobs(value, resources)}
blob={isEmote ? toEmoteWithBlobs(value, resources) : toWearableWithBlobs(value, resources)}
disableAutoRotate
disableBackground
{...wearablePreviewExtraOptions}
projection={PreviewProjection.ORTHOGRAPHIC}
camera={PreviewCamera.STATIC}
onLoad={handleLoad}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export interface Props {
resources?: File[]
onScreenshot: (value: string) => void
onLoad?: () => void
isEmote?: boolean
}
Loading
Loading