question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[gl-react-native]: <Saturate> seems not firing

See original GitHub issue

bug report

library version

image

Expected behavior

Expecting to have this https://gl-react-cookbook.surge.sh/saturation?brightness=0.9&contrast=0.95&saturation=0.9

Actual behavior

shows nothing inside the <Surface width={480} height={300}> and when I add debugger and console.log('ran') in the block of code of export const Saturate = ({ contrast, saturation, brightness, children }) => {, it doesn’t actually debug or console.

The gl.js is basically a copy of the link above, I changed gl-react-dom to gl-react-native though.

So I am not sure if I did anything incorrectly.

Steps to reproduce the behavior

index.js

//index.js
import Example from './gl';
class Photo extends Component {
  constructor(props) {
    ...
  }
      return (
        <View style={styles.body}>
          <Example/>
        </View>
      );
}

gl.js

//gl.js
import React, { Component } from 'react';
import { Shaders, Node, GLSL } from 'gl-react';
import { Surface } from 'gl-react-native';

const shaders = Shaders.create({
  Saturate: {
    frag: GLSL`
    precision highp float;
    varying vec2 uv;
    uniform sampler2D t;
    uniform float contrast, saturation, brightness;
    const vec3 L = vec3(0.2125, 0.7154, 0.0721);
    void main() {
      vec4 c = texture2D(t, uv);
      vec3 brt = c.rgb * brightness;
      gl_FragColor = vec4(mix(
      vec3(0.5),
      mix(vec3(dot(brt, L)), brt, saturation),
      contrast), c.a);
  }
  `
  }
});

export const Saturate = ({ contrast, saturation, brightness, children }) => {
  //console.log('ran');
  //debugger;  
  return (<Node
    shader={shaders.Saturate}
    uniforms={{ contrast, saturation, brightness, t: children }}
  />
)};

export default class Example extends Component {
  render() {
    return (
      <Surface width={480} height={300}>
        <Saturate {...this.props}>
          https://i.imgur.com/uTP9Xfr.jpg
        </Saturate>
      </Surface>
    );
  }
  static defaultProps = {
    contrast: 1,
    saturation: 1,
    brightness: 1
  };
}

image

================================================

Reason

Did not set up RNGL.xcodeproj correctly

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
josephmaximcommented, Jun 23, 2017

@edwardfhsiao Turn off remote debugger. that should fix it.

1reaction
grecommented, Jun 26, 2017

yeah, I’m afraid debugging won’t work like in the EXGLView implementation. as in WebGL spec, the gl calls needs to exec in sync, so we need to actively “block” the JS somehow. EXGLView impl expect the JS to run in JavascriptCore (because the gl.* method directly exec some C++ code with low overhead) but this can’t work inside Chrome (the remote debugging means executing the JS in Chrome instead of JSC).

I hope this was more documented in EXGLView and in gl-react-native README (or somewhere!) , feel free to send PR to improve that.

also @nikki93 can probably comment more on the technical reason of this choice 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why gl-react not working in react-native? - Stack Overflow
I am trying to use https://github.com/gre/gl-react-native and react-native-webgl in react-native(0.58.3) but it is not working, ...
Read more >
gl-react/Lobby - Gitter
i try to use webGL GL react to do saturation on image with react native. However, it printed out the error requireNative Component...
Read more >
Alert - React Native
Tapping any button will fire the respective onPress callback and dismiss the alert. By default, the only button will be an 'OK' button....
Read more >
Layers | Style Specification | Mapbox GL JS
Layers have two sub-properties that determine how data from that layer is rendered: layout and paint properties. Layout properties appear in the layer's...
Read more >
React Native Tutorial for Beginners - Build a React Native App
React Native Tutorial for Beginners - Learn to build an amazing React Native app for iOS & Android. Get the full...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found