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

context is null on AWS #76

Open
RaduMilici opened this issue Jun 24, 2016 · 8 comments
Open

context is null on AWS #76

RaduMilici opened this issue Jun 24, 2016 · 8 comments
Labels

Comments

@RaduMilici
Copy link

hello!
I'm trying really hard to get headless-gl to work on an AWS gpu enabled instance (EC2 gl2.2xlarge).
For the moment I'm not doing anything fancy, just the basic example but the gl context is not created, just null is returned.

I have the latest nvidia drivers installed and am using xvfb-run.
Also, this is logged as well: Xlib: extension "GLX" missing on display ":99".
I googled a lot for that error, set DISPLAY to equal :99, everything i could find, yet still nothing.

Locally headless-gl works just fine, and I think it's very interesting.
Thank you very much for reading and looking forward to any responses. Send help! :)

@ghost
Copy link

ghost commented Aug 17, 2016

I get the same error on desktop linux running debian with a radeon HD 8330 card. The new webgl.WebGLRenderingContext call throws with this error (which is ignored) :

Error: Error creating WebGLContext
    at Error (native)
    at createContext (/home/substack/projects/shader-compute/node_modules/gl/node_index.js:39:10)
    at Object.<anonymous> (/home/substack/projects/shader-compute/example/frame.js:1:86)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (bootstrap_node.js:352:7)

@ghost ghost reopened this Aug 17, 2016
@mikolalysenko
Copy link
Member

This is hard to debug. The output from the error message should be more descriptive.

@tehbelinda
Copy link

Did you start the x server? I had the same problem before that.

I followed the instructions under "# Install and configure X window with virtual screen" in http://stackoverflow.com/questions/19856192/run-opengl-on-aws-gpu-instances-with-centos
I was using the Ubuntu 14.04 AMI but still had to add the BusID to my /etc/X11/xorg.conf like in the accepted answer

Though now I'm running into this issue... #65

@ksze
Copy link

ksze commented Sep 7, 2017

I get the same traceback as @substack. If I want to use xvfb-run, is the GLX extension required?

Xpra's wiki seems to suggest that Xdummy may be a better solution (https://www.xpra.org/trac/wiki/Xdummy). Has anybody tried that?

@raphaelsetin
Copy link

I had the same problem when I was trying to render a model in ThreeJS using headless-gl, and after trying everything possible for 2-3 days straight, I was able to solve my problem using Puppeteer. I would advise you to do that instead as headless-gl didn't seem to work well, at least in AWS Lambda.

@vexcat
Copy link

vexcat commented May 22, 2021

I had the exact same problem on my desktop PC while trying to use headless-gl. Eventually I figured out it wasn't working because the DISPLAY variable wasn't set (I was using my desktop remotely over SSH).

After running

export DISPLAY=":1"

it works fine.

Not sure if this will help you run headless-gl on AWS, as you say you already had the DISPLAY variable set (and perhaps you may not be looking for solutions ~4 years later), but hopefully this saves somebody else the frustration I had!

@BrennerSpear
Copy link

I had the same problem when I was trying to render a model in ThreeJS using headless-gl, and after trying everything possible for 2-3 days straight, I was able to solve my problem using Puppeteer. I would advise you to do that instead as headless-gl didn't seem to work well, at least in AWS Lambda.

any chance you have some barebones / template code you can share?

@raphaelsetin
Copy link

raphaelsetin commented Dec 1, 2021

@BrennerSpear Yes, absolutely!

  1. Make sure you install both chrome-aws-lambda and puppeteer-core in your NodeJS AWS Lambda function.
    NOTE: I expect that you already know how to install NPM packages and use it in an AWS Lambda environment.
  2. In your main JS file, do something like this:
const chromium = require('chrome-aws-lambda');

(async () => {
    let browser, page;
    try {
        browser = await chromium.puppeteer.launch({
            args: chromium.args,
            defaultViewport: chromium.defaultViewport,
            executablePath: await chromium.executablePath,
            headless: true,
            ignoreHTTPSErrors: true
        });
        page = await browser.newPage();
        await page.setViewport({
	    width: 1920,
	    height: 1080
        });
        await page.goto('https://github.com/stackgl/headless-gl/issues/76');
		
	await browser.close();
    } catch (err) {
	console.error(`There was an error initializing browser for Puppeteer. Error: ${err}`);
    }
})();

In relation to how you can use ThreeJS, I suggest you (my setup would be quite complex to explain) to use Webpack to bundle an HTML, or bundle a React based page into an HTML in which you would upload/supply in your Lambda function. Having that local HTML in your /tmp/my-page.html folder for example would allow you to open it using Puppeteer, like:

await page.goto('/tmp/my-page.html');
// You would then call a function defined in your HTML to initialize the model that is present in your `tmp` folder
// Now you could call a function defined in your HTML using `await page.evaluate()` in which it would save a screenshot of your model and return the image data as a string
// The data returned could be saved into a PNG file in your `tmp` folder, and then saved to an S3 bucket

PS: I don't have much time to detail everything at the moment, but that's the general idea. I hope it helps 😃

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

No branches or pull requests

7 participants