hans00 / react-native-transformers-example

Example of transformers.js on React Native
43 stars 6 forks source link

Error running cloned repo #13

Closed ThomasSydney closed 1 year ago

ThomasSydney commented 1 year ago

Hello, I've attempted to build the repo for android (removing the GCanvasView parts) but unfortunately I'm getting an error when I try to generate anything, for example text generation, I'm getting this error:

 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.
 LOG  Running "transformers_example" with {"rootTag":11}
 LOG  No model specified. Using default model: "Xenova/gpt2".
 ERROR  [TypeError: undefined is not a function]

Any ideas?

Thanks!

hans00 commented 1 year ago

Did you remove polyfills? For language model, we need polyfill TextEncoder. And some model need replace RegExp

hans00 commented 1 year ago

Or maybe you can change to print traceback to get more info to debug.

https://github.com/hans00/react-native-transformers-example/blob/6664946483d0f81b71cefce198b6a4e9aa6b1b5e/App.tsx#L78

console.error(e.stack)
ThomasSydney commented 1 year ago

Hi thanks for the assistance, apologies for the delay in reply. I've reran with the stack trace as below:

WARN `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method. WARN `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method. LOG Running "transformers_example" with {"rootTag":11} LOG No model specified. Using default model: "Xenova/gpt2". ERROR TypeError: undefined is not a function at ?anon_0_ (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:145371:44) at next (native) at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20673:26) at _next (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20692:29) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20697:14) at tryCallTwo (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:61:9) at doResolve (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:216:25) at Promise (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:82:14) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20689:25) at apply (native) at match (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:145388:30) at ?anon_0_ (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:145456:37) at next (native) at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20673:26) at _next (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20692:29) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20697:14) at tryCallTwo (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:61:9) at doResolve (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:216:25) at Promise (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:82:14) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20689:25) at apply (native) at _getModelFile (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:145546:31) at apply (native) at getModelFile (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:145421:31) at ?anon_0_ (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:145555:38) at next (native) at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20673:26) at _next (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20692:29) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20697:14) at tryCallTwo (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:61:9) at doResolve (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:216:25) at Promise (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:82:14) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20689:25) at apply (native) at _getModelJSON (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:145564:31) at apply (native) at getModelJSON (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:145549:31) at ?anon_0_ (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:150870:104) at next (native) at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20673:26) at _next (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20692:29) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20697:14) at tryCallTwo (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:61:9) at doResolve (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:216:25) at Promise (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:82:14) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20689:25) at apply (native) at _loadTokenizer (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:150873:32) at apply (native) at loadTokenizer (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:150866:32) ... skipping 21 frames at _pipeline (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:150479:27) at apply (native) at pipeline (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:150421:27) at ?anon_0_ (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:110976:93) at next (native) at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20673:26) at _next (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20692:29) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20697:14) at tryCallTwo (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:61:9) at doResolve (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:216:25) at Promise (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:82:14) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20689:25) at apply (native) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:110994:26) at ?anon_0_ (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:119010:43) at next (native) at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20673:26) at _next (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20692:29) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20697:14) at tryCallTwo (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:61:9) at doResolve (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:216:25) at Promise (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/x86_64/lib/InternalBytecode/InternalBytecode.js:82:14) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:20689:25) at _performTransitionSideEffects (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:49345:22) at _receiveSignal (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:49301:45) at onResponderRelease (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:49168:34) at apply (native) at invokeGuardedCallbackProd (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:61134:21) at apply (native) at invokeGuardedCallback (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:61220:42) at apply (native) at invokeGuardedCallbackAndCatchFirstError (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:61223:36) at executeDispatch (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:61287:48) at executeDispatchesInOrder (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:61304:26) at executeDispatchesAndRelease (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:62410:35) at executeDispatchesAndReleaseTopLevel (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:62417:43) at forEach (native) at forEachAccumulated (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:61746:22) at runEventsInBatch (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:62428:27) at runExtractedPluginEventsInBatch (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:62487:25) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:62468:42) at batchedUpdates$1 (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:73058:20) at batchedUpdates (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:62399:36) at _receiveRootNodeIDEvent (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:62467:23) at receiveTouches (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:62510:34) at apply (native) at __callFunction (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:2443:36) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:2204:31) at __guard (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:2394:15) at callFunctionReturnFlushedQueue (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.transformers_example&modulesOnly=false&runModule=true:2203:21)

image

I haven't touched the polyfills, just commented out the GCanvas code. Sorry if I'm missing something really obvious!

hans00 commented 1 year ago

Hmm... Not sure what problem you face. (My test has no problem) Only know your error location is approx here.

These code is checking model file cache. Have you touched the dependency?

I recommend you use debugger to found the problem.

ThomasSydney commented 1 year ago

I managed to fix my issue by recloning the library and using yarn instead of npm. Not sure of the exact issue but thanks for your help @hans00 :)