Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it works on replit? #277

Closed
onchainyaotoshi opened this issue Mar 1, 2024 · 8 comments
Closed

Does it works on replit? #277

onchainyaotoshi opened this issue Mar 1, 2024 · 8 comments

Comments

@onchainyaotoshi
Copy link

onchainyaotoshi commented Mar 1, 2024

I also try to running with below scripts:
xvfb-run :99 -screen 0 1280x1024x24 & export DISPLAY=:99; npm run start:live
xvfb-run :99 -screen 0 1024x768x24 & export DISPLAY=:99; npm run start:live
xvfb-run -s "-ac -screen 0 1024x768x24" npm run start:live
xvfb-run --auto-servernum --server-num=1 -s "-ac -screen 0 1280x1024x24" npm run start:live

with gl version: "^6.0.2",

Errors:

THREE.WebGLRenderer: Error creating WebGL context.
file:///home/runner/frame-cube/node_modules/three/build/three.module.js:28929
throw new Error( 'Error creating WebGL context.' );
^

Error: Error creating WebGL context.
at new WebGLRenderer (file:///home/runner/frame-cube/node_modules/three/build/three.module.js:28929:13)
at CubeView.initScene (file:///home/runner/frame-cube/src/utils/rubik/cube-view.js:34:21)
at new CubeView (file:///home/runner/frame-cube/src/utils/rubik/cube-view.js:12:10)
at Rubik.renderToBase64 (file:///home/runner/frame-cube/src/utils/rubik/index.js:23:17)
at renderFrameUnsolvedRubik (file:///home/runner/frame-cube/src/controllers/rubik-controller.js:32:18)
at startSession (file:///home/runner/frame-cube/src/controllers/rubik-controller.js:72:5)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

@dhritzkiv
Copy link
Member

Hi there.

I'm not familiar with replit, so I can't completely offer any advice on what may be going on there.

What output do you see if you run

xvfb-run --auto-servernum -s "-ac -screen 0 1024x768x24" `which glxinfo`

@onchainyaotoshi
Copy link
Author

onchainyaotoshi commented Mar 2, 2024

so i manage to install glxinfo and it returns:

/nix/store/00rxyj8xxpq1sadd3adm6q6ls7hx0rmx-mesa-demos-9.0.0/bin/glxinfo

if i run glxinfo without xvfb:

name of display: :0
Error: couldn't find RGB GLX visual or fbconfig

Screenshot_55

@onchainyaotoshi
Copy link
Author

so i create a file check-gl.js to test it on replit which is a linux platform too.

import createGL from 'gl';

function delay(time) {
  return new Promise(resolve => setTimeout(resolve, time));
} 

const ctx = createGL(300, 300);
console.log("ctx", null);

await delay(5000);
throw new Error('finish');

and i run the script with:

xvfb-run --auto-servernum -s "-ac -screen 0 1024x768x24" node ./scripts/check-gl.js

and the result is "ctx null"

Screenshot_54

@dhritzkiv
Copy link
Member

Have you made sure to install the relevant dependencies for your system?

  • mesa-utils
  • libgl1-mesa-dri
  • libglapi-mesa
  • libosmesa6

Note: these dependencies vary by system, and I'm not familiar with the replit environment, so I can't advise more specifically.

@onchainyaotoshi
Copy link
Author

onchainyaotoshi commented Mar 3, 2024

I have installed all the necessary packages through replit.nix. Without these installations, the node-gyp build phase would not complete successfully.

{ pkgs }: {
  
  deps = [
      pkgs.vim-full
      pkgs.pciutils
    pkgs.postgresql
    pkgs.nodejs_20
    pkgs.python310Full

    #for node-gyp (build-essential)
    pkgs.gcc
    pkgs.gnumake

    #for gl & canvas
    pkgs.pkg-config
    pkgs.xvfb-run
  
    #for gl node-gyp build
    pkgs.mesa
    pkgs.mesa-demos

    #for fix couldn't find RGB GLX visual or fbconfig when run this shell command: xvfb-run --auto-servernum -s "-ac -screen 0 1024x768x24" glxinfo

    #for canvas 
    pkgs.cairo
    pkgs.pango
    pkgs.libjpeg
    pkgs.giflib
    pkgs.librsvg
    pkgs.libuuid
    pkgs.binutils
    
    # Add other dependencies here
  ];

  #https://github.com/Automattic/node-canvas/issues/1893#issuecomment-1096988007
  env = { 
    LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
      pkgs.libuuid
    ];
    PYTHONHOME = "${pkgs.python310Full}";
    PYTHONBIN = "${pkgs.python310Full}/bin/python3.10";
    LANG = "en_US.UTF-8";
  }; 
}

@onchainyaotoshi
Copy link
Author

So, I am considering leaving it as is and migrating to another hosting site. Do you have any suggestions for hosting sites that might support these packages?

@onchainyaotoshi
Copy link
Author

I just moved to DigitalOcean, and it works now. Thanks for your help, bro!

@dhritzkiv
Copy link
Member

Glad you were able to get it to work.

Generally, it shouldn't depend on a specific hosting provider – it more so depends on the environment that you're trying to get it to work in, and what complications/restrictions it imposes. It's possible with more work you might have been able to get it set up in Replit/Nix, but it seems like there were an unknown number of obstacles in the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants