ReactVision / viro

ViroReact: The AR and VR library for React Native πŸ“³πŸ’™πŸ’›πŸ€πŸ’š
MIT License
1.41k stars 164 forks source link

Issue: Delay in Loading 3D Objects with Viro3DObject Component #311

Open purevsurena opened 1 month ago

purevsurena commented 1 month ago

Issue: Delay in Loading 3D Objects with Viro3DObject Component

Requirements Checklist

Environment

Description When using the Viro3DObject component to render GLB files, I’m encountering significant delays in loading times. For instance, loading a small GLB file (e.g., 2MB) sometimes takes over 10 seconds, particularly when switching to the next object.

Upon investigation:

The onLoadStart event fires immediately, indicating the loading process initiates without delay. However, the onLoadEnd event sometimes takes a long time to trigger, leading to an extended wait before the object displays. This issue impacts the user experience, as it interrupts responsiveness and creates noticeable delays.

<Viro3DObject
    key={objectKey}
    ref={viro3DObjectRef}
    animation={{ name: 'rotate', loop: true, run: true }}
    source={{
        uri: getS3Url(three_d_url),
    }}
    highAccuracyEvents
    position={[position.positionX, position.positionY, position.positionZ]}
    scale={scale}
    type="GLB"
    onLoadStart={handleLoadStart}
    onLoadEnd={handleLoadEnd}
    onError={handleLoadError}
    visible={!isLoading && !glbLoaded}
    onDrag={handleOnDrag}
    onPinch={handleOnPinch}
    dragType="FixedToWorld"
/>

const handleLoadStart = useCallback(() => {
    setIsLoading(true);
    setGlbLoaded(false);
}, []);

const handleLoadEnd = useCallback(() => {
    setIsLoading(false);
    setGlbLoaded(true);
}, []);

Reproducible Demo

Steps to reproduce the issue:

  1. Load a GLB file using the code provided in the Viro3DObject component.
  2. Observe the delay between onLoadStart and onLoadEnd events, particularly when switching between objects.
  3. Delays are inconsistent but often significant.