@candide/react-native-gpu-info

Extracts information about the GPU on Android devices

Usage no npm install needed!

<script type="module">
  import candideReactNativeGpuInfo from 'https://cdn.skypack.dev/@candide/react-native-gpu-info';
</script>

README

react-native-gpu-info

Getting started

$ npm install react-native-gpu-info --save

Mostly automatic installation

$ react-native link react-native-gpu-info

Manual installation

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.reactlibrary.RNGpuInfoPackage; to the imports at the top of the file
  • Add new RNGpuInfoPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-gpu-info'
    project(':react-native-gpu-info').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-gpu-info/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-gpu-info')
    

Usage

Within your host activity add the following code;

public class MainActivity extends ReactActivity { 
    private GlSurfaceInspector surfaceInspector = new GlSurfaceInspector();

    @Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            surfaceInspector.init(this);
    }

    @Override
    protected void onPause() {
            super.onPause();
            surfaceInspector.onPause();
    }

    @Override
    protected void onResume() {
            super.onResume();
            surfaceInspector.onResume();
    }
}

Then in your Javascript code import the library;

import RNGpuInfo from 'react-native-gpu-info';

And retrieve the name of the GPU chip via;

const glRenderer = RNGpuInfo.getGlRenderer()