digitalcredentials / learner-credential-wallet

Learner Credential Wallet is a cross-platform iOS and Android mobile application for storing and sharing digital learner credentials.
https://lcw.app
MIT License
53 stars 26 forks source link

OWF: ReferenceError: Property 'Buffer' doesn't exist, js engine: hermes #577

Closed kezike closed 2 months ago

kezike commented 5 months ago

Describe the bug While running the LCW app on a hardware Android device, I encounter the following error:

 ERROR  ReferenceError: Property 'Buffer' doesn't exist, js engine: hermes
 ERROR  Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes

Additionally, it seems that the Metro recognizes the device to be iOS, considering the value of the platform query parameter of the URL located at the path $.launchAsset.url at http://localhost:8081:

{
  "id": "0bdc1a2b-20ed-4cd0-a460-f8959804efa0",
  "createdAt": "2024-03-07T22:27:22.388Z",
  "runtimeVersion": "1.0.0",
  "launchAsset": {
    "key": "bundle",
    "contentType": "application/javascript",
    "url": "http://127.0.0.1:8081/index.bundle?platform=ios&dev=true&hot=false&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app"
  },
  "assets": [],
  "metadata": {},
  "extra": {
    "eas": {},
    "expoClient": {
      "runtimeVersion": "1.0.0",
      "name": "Learner Credential Wallet",
      "slug": "learner-credential-wallet",
      "version": "1.0.0",
      "orientation": "portrait",
      "icon": "./app/assets/icon.png",
      "backgroundColor": "#1F2937",
      "splash": {
        "image": "./app/assets/splash.png",
        "resizeMode": "contain",
        "backgroundColor": "#1F2937",
        "imageUrl": "http://127.0.0.1:8081/assets/./app/assets/splash.png"
      },
      "updates": {
        "fallbackToCacheTimeout": 0
      },
      "assetBundlePatterns": [
        "**/*"
      ],
      "ios": {
        "supportsTablet": true,
        "bundleIdentifier": "edu.mit.eduwallet",
        "entitlements": {
          "com.apple.security.application-groups": [
            "group.edu.mit.eduwallet"
          ]
        },
        "associatedDomains": [
          "applinks:lcw.app/mobile"
        ],
        "infoPlist": {
          "CFBundleURLTypes": [
            {
              "CFBundleURLSchemes": [
                "dccrequest"
              ]
            }
          ],
          "NSCameraUsageDescription": "$(PRODUCT_NAME) needs access to your Camera to scan QR codes."
        }
      },
      "android": {
        "adaptiveIcon": {
          "foregroundImage": "./app/assets/adaptive-icon.png",
          "backgroundColor": "#1F2937",
          "foregroundImageUrl": "http://127.0.0.1:8081/assets/./app/assets/adaptive-icon.png"
        },
        "intentFilters": [
          {
            "action": "VIEW",
            "autoVerify": false,
            "data": [
              {
                "scheme": "dccrequest",
                "host": "request"
              },
              {
                "scheme": "dccrequest",
                "host": "present"
              }
            ],
            "category": [
              "BROWSABLE",
              "DEFAULT"
            ]
          }
        ],
        "package": "edu.wallet",
        "permissions": [
          "android.permission.CAMERA"
        ]
      },
      "web": {
        "favicon": "./app/assets/favicon.png"
      },
      "plugins": [
        [
          "react-native-vision-camera",
          {
            "cameraPermissionText": "$(PRODUCT_NAME) needs access to your Camera to scan QR codes.",
            "enableMicrophonePermission": false,
            "enableCodeScanner": true
          }
        ]
      ],
      "_internal": {
        "isDebug": false,
        "projectRoot": "/Users/.../learner-credential-wallet",
        "dynamicConfigPath": {},
        "staticConfigPath": "/Users/.../learner-credential-wallet/app.json",
        "packageJsonPath": "/Users/.../learner-credential-wallet/package.json",
        "pluginHistory": {
          "react-native-vision-camera": {
            "name": "react-native-vision-camera",
            "version": "3.9.1"
          }
        }
      },
      "sdkVersion": "50.0.0",
      "platforms": [
        "ios",
        "android"
      ],
      "iconUrl": "http://127.0.0.1:8081/assets/./app/assets/icon.png",
      "hostUri": "127.0.0.1:8081"
    },
    "expoGo": {
      "debuggerHost": "127.0.0.1:8081",
      "developer": {
        "tool": "expo-cli",
        "projectRoot": "/Users/.../learner-credential-wallet"
      },
      "packagerOpts": {
        "dev": true
      },
      "mainModuleName": "index",
      "__flipperHack": "React Native packager is running"
    },
    "scopeKey": "@anonymous/learner-credential-wallet-c93e2f75-6a43-4dad-9a1f-134a820203bb"
  }
}

To Reproduce Steps to reproduce the behavior:

  1. Clone LCW repo
  2. Run npm i --legacy-peer-deps
  3. Run npm run prebuild:android
  4. Run npm start in one terminal window
  5. Run npm run android in another window
  6. Observe error

Expected behavior App should launch on Android device without issue.

Smartphone:

vonovak commented 5 months ago

Hello, I tried to reproduce this given the above steps, but for me the app builds and runs fine. So unfortunately, this is not actionable for me at this point.

With regard to launchAsset, I'm not sure what the field is exactly, but I don't think it's a problem - I see the same stuff when I go to http://localhost:8081/ and the app works for me. Metro doesn't perform any device detection afaik, it just serves what you ask it to serve.

alexfigtree commented 5 months ago

@kezike Not sure what happened, but I can no longer replicate this issue on my end either. Is this still happening for you? If not, we can close this issue.

alexfigtree commented 4 months ago

@dmitrizagidulin Just reproduced this on a fresh install. Re-assigning to @vonovak .

alexfigtree commented 3 months ago

Update: fix in store, but not on main branch yet.

alexfigtree commented 2 months ago

Quick fix still needed before merging PR, then can be moved to Done after main gets deployed to app store: https://github.com/digitalcredentials/learner-credential-wallet/pull/599/files

alexfigtree commented 2 months ago

Deployed to both Google Play and App Store (release 2.1.0-build80), closing ticket.