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

Channels effect crashes when setting alphaSource when source is undefined #109

Open
positlabs opened this issue Oct 29, 2015 · 6 comments
Open

Comments

@positlabs
Copy link

I tried making an alpha mask for a webcam feed, but it's failing if I assign alphaSource immediately after instantiating the channels effect.

            var img = document.createElement('img');
            img.src = 'assets/imgs/alphamask-test.png';

            var cameraMask = seriously.effect('channels');
            cameraMask.alphaSource = seriously.source(img); // fails!

But if I wait a tick, it works just fine.

            setTimeout(function(){
                cameraMask.alphaSource = seriously.source(img); // succeeds!
            }, 1);

Seems like it's probably a simple thing to fix, but for now I'll use this workaround.

Here's some screenshots, in case they help.

screen shot 2015-10-29 at 11 00 17 am

screen shot 2015-10-29 at 11 00 28 am

@positlabs
Copy link
Author

Seems like there is also a problem when setting cameraMask.source a second time. I get this error: Uncaught TypeError: Cannot read property 'useProgram' of undefined

@positlabs
Copy link
Author

Maybe not the best approach, but checking for undefined source before adding it to the array works. It fixes the issue of having to delay assigning source, but not the issue of reassigning source.

        function validateSource(name) {
            ...
            if (j < 0 && s !== undefined) {
                ...
            }
        }

@brianchirls
Copy link
Owner

Thanks for reporting. I'm making some progress on this. Can you share some sample code or a stacktrace for the reassigning source problem?

@brianchirls brianchirls changed the title Channels Channels effect crashes when setting alphaSource when source is undefined Oct 29, 2015
@brianchirls
Copy link
Owner

Looks like the reason your workaround works is that somewhere after the setTimeout, you set a source or another channel on that node. So it's not really about waiting a tick - it's just about setting alphaSource after another input. Is that right?

@positlabs
Copy link
Author

I'll work on making a test case.

Yep, assigning source before alphaSource does the trick!

Here are some shots of what happens when I try switching source after it's been assigned once.

screen shot 2015-10-29 at 2 02 30 pm

screen shot 2015-10-29 at 2 02 49 pm

@positlabs
Copy link
Author

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