Skip to content

fast-png dependency creates a latin1 TextDecoder at import-time, crashing runtimes that don't contain latin1 support #1162

@cn1001wang

Description

@cn1001wang

Environment

  • roslib version: 2.x (latest)
  • Platform: React Native (Expo Bare)
  • JS engine: Hermes
  • OS: Android (also reproducible on iOS with Hermes)
  • Transport: rosbridge WebSocket

Description

After upgrading from roslib 1.4.1 to 2.x, the app crashes at startup in a React Native environment using Hermes. The error appears to originate from dependencies (likely BSON / Buffer usage) that rely on encodings unsupported by Hermes.

Error Logs

WARN  BSON: For React Native please polyfill crypto.getRandomValues
ERROR RangeError: Unknown encoding: latin1 (normalized: latin1), js engine: hermes

Steps to Reproduce

  1. Create a React Native project (Expo Bare or CLI).
  2. Enable Hermes (default in recent RN versions).
  3. Install roslib 2.x:
npm install roslib
  1. Import and create a Ros instance:
import { Ros } from 'roslib'

const ros = new Ros({
  url: 'ws://localhost:9090'
})
  1. Run on Android or iOS.

Expected Behavior

roslib should initialize normally in React Native, or documentation should clarify that RN is not supported.

Actual Behavior

Application crashes with:

RangeError: Unknown encoding: latin1

Questions

  1. Is React Native (Hermes) officially supported in roslib v2?
  2. Are there recommended polyfills or configuration steps to make v2 work in RN?
  3. If RN is not supported, would it be possible to document this limitation?
  4. Is there any plan to provide a RN-compatible build (without Node-specific encoding dependencies)?

Thank you!

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions