NativeScript / canvas

Apache License 2.0
88 stars 18 forks source link

App Crashes or self is not defined | Pixi, Canvas, Polyfill #52

Closed red-game-dev closed 2 years ago

red-game-dev commented 3 years ago

Hi!

Hope you're well.

I am trying to integrate pixijs on nativescript so I can utilize, but I'm facing an issue which unfortunately does crash the app at any case when I integrate the @nativescript/canvas, @nativescript/canvas-polyfill, @nativescript/canvas-pixi.

Platform: Android

NS version: 8.0.2 Npm version: 6.14.13 Node version: v14.17.0 Packages versions:

What have I tried so far?

I've added an example of this testCanvasApp.zip

Few issues I've faced so far

Looking forward to hearing from you, and hopefully I can be assisted and fixed if there is any issue.

Best regards, Cheers

triniwiz commented 3 years ago

Can you use the beta versions of pixi + polyfill

"@nativescript/canvas-pixi": "beta",
"@nativescript/canvas-polyfill": "beta"
red-game-dev commented 3 years ago

Hi @triniwiz !

Thank you for your quick response. As suggested I've checked out the versions asked, but still the same issue unfortunately, regards to ReferenceError: self is not defined

Preview and the packages being used (Same as the example sent on previous comment) image

I've updated the demo package, which you can access below, with the respective versions mentioned. testCanvasApp.zip

Looking forward to hearing from you.

Best regards, Cheers

triniwiz commented 3 years ago

Ah I see you are using v6 I haven't test that version , the demo in this project uses ^5.3.3

red-game-dev commented 3 years ago

Hi @triniwiz

I've tried with the respective version mentioned, which seems we've progressed a bit, but a new error has appeared which is window is not defined.

I've tried few things as well from the What I tried so far in https://github.com/NativeScript/canvas/issues/52#issue-993489197, but nothing worked either.

Uploaded a sample app with the updated version recommended testCanvasApp.zip

Looking forward to hearing from you.

Best regards, Cheers

triniwiz commented 3 years ago

A couple things from your demo

  1. Pixi import .so pixi.js seems to be trying to test the canvas support this seems to be breaking the app for android since no activity has been created , you can solve this by moving around the imports to when you are about to use them
  2. You should turn on logging for now to make things a bit easier Vue.config.silent = false;
  3. @ready event you are not using your created event
  4. You do not need xmlns:canvas="@nativescript/canvas" since the app is not using the core flavour
red-game-dev commented 3 years ago

Hi @triniwiz

Hope you're well! My apologies for the late reply, but couldn't reply anytime sooner.

Latest Demo: testCanvasApp.zip

Suggestion: Would it be possible for us to have a small docs of how to use it a small step by step example?

Looking forward to hearing from you.

Best regards, Cheers

triniwiz commented 3 years ago

I do plan on writing up some docs on using the canvas for now I updated your sample testCanvasApp.zip

red-game-dev commented 3 years ago

Hi @triniwiz !

Thank you for updating the sample, it is very helpful to get aligned, especially for new developers who will try this plugin!

Unfortunately, still keeps crashing for me without any error message, as well through adb logcat. I am not sure if it has been tested, I assume it was, which I was checking where the issue is coming from, which seems TNSPIXIApplication is the main issue.

I believe, I will wait the docs and perhaps see further where is the issue coming from in TNSPIXIApplication, but for the time being have got to postponed as I've got few priorities to be done by end of the month. Should there be any information, logging or such from my end, I'll let you know.

Thank you for this amazing effort, work put for these plugins!

Looking forward to hearing from you.

Best regards, Cheers

triniwiz commented 3 years ago

Interesting the demo I sent you works fine for me

red-game-dev commented 3 years ago

Interesting as well, as seems something wrong when TNSPIXIApplication is being called. What I can do ism reviewing it further then and see in case I've something wrong on my end. In case I've some logging will let you know, as well what logging would be useful for you? Will try to see further from there

Looking forward to hearing from you.

Best regards, Cheers

red-game-dev commented 3 years ago

Hi @triniwiz

Hope you're well! I'd like to let you know a small update about this through out the testing with your latest update.

I've given a try the changes you made on a real device and seems to be all working fine, although on the Emulator it doesn't work at all.

Below you can find the specsi I am using for this

Name: Pixel_3_API_29
CPU/ABI: Google Play Intel Atom (x86)
Path: C:\Users\<username>\.android\avd\Pixel_3_API_29_-_Work.avd
Target: google_apis_playstore [Google Play] (API level 29)
Skin: pixel_3
SD Card: 512M
fastboot.chosenSnapshotFile: 
runtime.network.speed: full
hw.accelerometer: yes
hw.device.name: pixel_3
hw.lcd.width: 1080
hw.initialOrientation: Portrait
image.androidVersion.api: 29
tag.id: google_apis_playstore
hw.mainKeys: no
hw.camera.front: emulated
avd.ini.displayname: Pixel 3 API 29 - Work
hw.gpu.mode: auto
hw.ramSize: 1536
PlayStore.enabled: true
fastboot.forceColdBoot: no
hw.cpu.ncore: 4
hw.keyboard: yes
hw.sensors.proximity: yes
hw.dPad: no
hw.lcd.height: 2160
vm.heapSize: 256
skin.dynamic: yes
hw.device.manufacturer: Google
hw.gps: yes
hw.audioInput: yes
image.sysdir.1: system-images\android-29\google_apis_playstore\x86\
showDeviceFrame: yes
hw.camera.back: virtualscene
AvdId: Pixel_3_API_29
hw.lcd.density: 440
hw.arc: false
hw.device.hash2: MD5:8a60718609e0741c7c0cc225f49c5590
fastboot.forceChosenSnapshotBoot: no
fastboot.forceFastBoot: yes
hw.trackBall: no
hw.battery: yes
hw.sdCard: yes
tag.display: Google Play
runtime.network.latency: none
disk.dataPartition.size: 6442450944
hw.sensors.orientation: yes
avd.ini.encoding: UTF-8
hw.gpu.enabled: yes

Regards to the device that it is working is Samsung S8 Plus.

I hope this could be helpful information to you and looking forward to hearing from you

Best regards, Cheers

triniwiz commented 3 years ago

Thanks for trying, is there any error you can share ?

red-game-dev commented 3 years ago

You're welcome!

Regards to errors, I've taken the logcat during the opening of application and crashing on Emulator, which hopefully could be helpful for you

Logging

oid.runtime/lib/libart.so (mterp_op_invoke_static+33) (BuildId: 895645e5113da057
f27d9b2ec11eb3bf)
09-19 02:24:26.485 14783 14783 F DEBUG   :       #14 pc 000e25fa  /apex/com.andr
oid.runtime/javalib/core-oj.jar (java.lang.Runtime.nativeLoad+2)
09-19 02:24:26.485 14783 14783 F DEBUG   :       #15 pc 00684f6c  /apex/com.andr
oid.runtime/lib/libart.so (MterpInvokeStatic+1260) (BuildId: 895645e5113da057f27
d9b2ec11eb3bf)
09-19 02:24:26.485 14783 14783 F DEBUG   :       #16 pc 001389a1  /apex/com.andr
oid.runtime/lib/libart.so (mterp_op_invoke_static+33) (BuildId: 895645e5113da057
f27d9b2ec11eb3bf)
09-19 02:24:26.485 14783 14783 F DEBUG   :       #17 pc 000e2afe  /apex/com.andr
oid.runtime/javalib/core-oj.jar (java.lang.Runtime.loadLibrary0+46)
09-19 02:24:26.485 14783 14783 F DEBUG   :       #18 pc 006845ac  /apex/com.andr
oid.runtime/lib/libart.so (MterpInvokeDirect+1324) (BuildId: 895645e5113da057f27
d9b2ec11eb3bf)
09-19 02:24:26.485 14783 14783 F DEBUG   :       #19 pc 00138921  /apex/com.andr
oid.runtime/lib/libart.so (mterp_op_invoke_direct+33) (BuildId: 895645e5113da057
f27d9b2ec11eb3bf)
09-19 02:24:26.485 14783 14783 F DEBUG   :       #20 pc 000e2ab8  /apex/com.andr
oid.runtime/javalib/core-oj.jar (java.lang.Runtime.loadLibrary0+8)
09-19 02:24:26.485 14783 14783 F DEBUG   :       #21 pc 00681adc  /apex/com.andr
oid.runtime/lib/libart.so (MterpInvokeVirtual+1612) (BuildId: 895645e5113da057f2
7d9b2ec11eb3bf)
09-19 02:24:26.485 14783 14783 F DEBUG   :       #22 pc 00138821  /apex/com.andr
oid.runtime/lib/libart.so (mterp_op_invoke_virtual+33) (BuildId: 895645e5113da05
7f27d9b2ec11eb3bf)
09-19 02:24:26.485 14783 14783 F DEBUG   :       #23 pc 000e805c  /apex/com.andr
oid.runtime/javalib/core-oj.jar (java.lang.System.loadLibrary+16)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #24 pc 002f8e0a  /apex/com.andr
oid.runtime/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20Code
ItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.12194892193087984976+298)
(BuildId: 895645e5113da057f27d9b2ec11eb3bf)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #25 pc 002ffcc5  /apex/com.andr
oid.runtime/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art:
:Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+181) (BuildId: 89
5645e5113da057f27d9b2ec11eb3bf)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #26 pc 0066fbd9  /apex/com.andr
oid.runtime/lib/libart.so (artQuickToInterpreterBridge+1209) (BuildId: 895645e51
13da057f27d9b2ec11eb3bf)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #27 pc 0014503d  /apex/com.andr
oid.runtime/lib/libart.so (art_quick_to_interpreter_bridge+77) (BuildId: 895645e
5113da057f27d9b2ec11eb3bf)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #28 pc 0013e9a2  /apex/com.andr
oid.runtime/lib/libart.so (art_quick_invoke_static_stub+418) (BuildId: 895645e51
13da057f27d9b2ec11eb3bf)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #29 pc 00149a7a  /apex/com.andr
oid.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, u
nsigned int, art::JValue*, char const*)+298) (BuildId: 895645e5113da057f27d9b2ec
11eb3bf)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #30 pc 0055a513  /apex/com.andr
oid.runtime/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::S
copedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namesp
ace)::ArgArray*, art::JValue*, char const*)+99) (BuildId: 895645e5113da057f27d9b
2ec11eb3bf)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #31 pc 0055b46e  /apex/com.andr
oid.runtime/lib/libart.so (art::InvokeWithJValues(art::ScopedObjectAccessAlready
Runnable const&, _jobject*, _jmethodID*, jvalue const*)+430) (BuildId: 895645e51
13da057f27d9b2ec11eb3bf)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #32 pc 00430d9d  /apex/com.andr
oid.runtime/lib/libart.so (art::JNI::CallStaticVoidMethodA(_JNIEnv*, _jclass*, _
jmethodID*, jvalue const*)+893) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #33 pc 003daaf5  /apex/com.andr
oid.runtime/lib/libart.so (art::(anonymous namespace)::CheckJNI::CallMethodA(cha
r const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, jvalue const*, art::Primit
ive::Type, art::InvokeType)+2293) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #34 pc 003c7579  /apex/com.andr
oid.runtime/lib/libart.so (art::(anonymous namespace)::CheckJNI::CallStaticVoidM
ethodA(_JNIEnv*, _jclass*, _jmethodID*, jvalue const*)+73) (BuildId: 895645e5113
da057f27d9b2ec11eb3bf)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #35 pc 001db3de  /data/app/org.
nativescript.testCanvasApp-4Gfnqj0xVDD4IcivnrODUg==/base.apk!libNativeScript.so
(offset 0x3023000) (BuildId: ab78e886585a64e1dc9cc655fa33db7d7b9c31ec)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #36 pc 001ccd1e  /data/app/org.
nativescript.testCanvasApp-4Gfnqj0xVDD4IcivnrODUg==/base.apk!libNativeScript.so
(offset 0x3023000) (BuildId: ab78e886585a64e1dc9cc655fa33db7d7b9c31ec)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #37 pc 001f46fb  /data/app/org.
nativescript.testCanvasApp-4Gfnqj0xVDD4IcivnrODUg==/base.apk!libNativeScript.so
(offset 0x3023000) (BuildId: ab78e886585a64e1dc9cc655fa33db7d7b9c31ec)
09-19 02:24:26.486 14783 14783 F DEBUG   :       #38 pc 00a174a3  /data/app/org.
nativescript.testCanvasApp-4Gfnqj0xVDD4IcivnrODUg==/base.apk!libNativeScript.so
(offset 0x3023000) (BuildId: ab78e886585a64e1dc9cc655fa33db7d7b9c31ec)
09-19 02:24:26.723  1865  1865 E /system/bin/tombstoned: Tombstone written to: /
data/tombstones/tombstone_06
09-19 02:24:26.729  2036 14786 W ActivityTaskManager:   Force finishing activity
 org.nativescript.testCanvasApp/com.tns.NativeScriptActivity
09-19 02:24:26.732  2036 14786 W InputReader: Device has associated, but no asso
ciated display id.
09-19 02:24:26.741  2036 14787 I DropBoxManagerService: add tag=data_app_native_
crash isTagEnabled=true flags=0x2
09-19 02:24:26.742  2036  2072 I BootReceiver: Copying /data/tombstones/tombston
e_06 to DropBox (SYSTEM_TOMBSTONE)
09-19 02:24:26.743  2036  2072 I DropBoxManagerService: add tag=SYSTEM_TOMBSTONE
 isTagEnabled=true flags=0x2
09-19 02:24:26.747  2036  2066 W BroadcastQueue: Background execution not allowe
d: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (ha
s extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
09-19 02:24:26.747  2036  2066 W BroadcastQueue: Background execution not allowe
d: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (ha
s extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$Persist
entTrustedReceiver
09-19 02:24:26.758  2036  2066 W BroadcastQueue: Background execution not allowe
d: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (ha
s extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
09-19 02:24:26.758  2036  2066 W BroadcastQueue: Background execution not allowe
d: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (ha
s extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$Persist
entTrustedReceiver
09-19 02:24:26.732  2036 14786 I chatty  : uid=1000 system_server identical 8 li
nes
09-19 02:24:26.732  2036 14786 W InputReader: Device has associated, but no asso
ciated display id.
09-19 02:24:26.801  1775  1775 I Zygote  : Process 14751 exited due to signal 4
(Illegal instruction)
09-19 02:24:26.802  2036  2915 I ActivityManager: Process org.nativescript.testC
anvasApp (pid 14751) has died: vis+99 TOP
09-19 02:24:26.802  2036  2068 I libprocessgroup: Successfully killed process cg
roup uid 10143 pid 14751 in 0ms
09-19 02:24:26.808  2036  2915 W InputReader: Device has associated, but no asso
ciated display id.
09-19 02:24:26.825  2036  2061 W WindowManager: Failed looking up window callers
=com.android.server.wm.WindowManagerService.windowForClientLocked:5281 com.andro
id.server.wm.WindowManagerService.removeWindow:1753 com.android.server.wm.Sessio
n.remove:176
09-19 02:24:26.816  2036  2915 I chatty  : uid=1000(system) Binder:2036_C identi
cal 18 lines
09-19 02:24:26.816  2036  2915 W InputReader: Device has associated, but no asso
ciated display id.
09-19 02:24:26.840  1806  1806 D gralloc_ranchu: gralloc_alloc: Creating ashmem
region of size 9334784
09-19 02:24:26.866  1806  1806 D gralloc_ranchu: gralloc_alloc: Creating ashmem
region of size 9334784
09-19 02:24:26.868  1806  3133 D gralloc_ranchu: gralloc_alloc: Creating ashmem
region of size 9334784
09-19 02:24:26.879  2186  2520 D EGL_emulation: eglMakeCurrent: 0xe7e04400: ver
2 0 (tinfo 0xc781d220)
09-19 02:24:26.889  2448  3023 D EGL_emulation: eglMakeCurrent: 0xdfd1a300: ver
2 0 (tinfo 0xdfd0f8c0)
09-19 02:24:26.909  2036  2036 W ActivityManager: Unable to start service Intent
 { act=android.service.appprediction.AppPredictionService cmp=com.google.android
.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } U=0: not fo
und
09-19 02:24:26.909  2036  2036 W RemoteAppPredictionService: could not bind to I
ntent { act=android.service.appprediction.AppPredictionService cmp=com.google.an
droid.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } using
flags 67108865
09-19 02:24:26.937  1806  1806 D gralloc_ranchu: gralloc_alloc: Creating ashmem
region of size 9334784
09-19 02:24:26.939  5791  5906 D EGL_emulation: eglMakeCurrent: 0xdc78bf40: ver
2 0 (tinfo 0xbda2d230)
09-19 02:24:26.956  1806  3133 D gralloc_ranchu: gralloc_alloc: Creating ashmem
region of size 9334784
09-19 02:24:26.986  5791  5913 I MicroDetectionState: Should stop hotword detect
ion immediately - true
09-19 02:24:26.987  1806  1806 D gralloc_ranchu: gralloc_alloc: Creating ashmem
region of size 9334784
09-19 02:24:26.988  2186  2520 D EGL_emulation: eglMakeCurrent: 0xe7e04400: ver
2 0 (tinfo 0xc781d220)
09-19 02:24:27.233  2036  2060 W ActivityTaskManager: Activity top resumed state
 loss timeout for ActivityRecord{df335a0 u0 org.nativescript.testCanvasApp/com.t
ns.NativeScriptActivity t-1 f}
09-19 02:24:27.010  2186  2520 I chatty  : uid=10103(com.android.systemui) Rende
rThread identical 2 lines
09-19 02:24:27.013  2186  2520 D EGL_emulation: eglMakeCurrent: 0xe7e04400: ver
2 0 (tinfo 0xc781d220)
09-19 02:24:27.478  1805  2283 E GnssHAL_GnssInterface: gnssSvStatusCb: a: input
 svInfo.flags is 8
09-19 02:24:27.478  1805  2283 E GnssHAL_GnssInterface: gnssSvStatusCb: b: input
 svInfo.flags is 8
09-19 02:24:27.803  1781  1781 W audio_hw_generic: Not supplying enough data to
HAL, expected position 1296532 , only wrote 1159394
09-19 02:24:28.478  1805  2283 E GnssHAL_GnssInterface: gnssSvStatusCb: a: input
 svInfo.flags is 8
09-19 02:24:28.478  1805  2283 E GnssHAL_GnssInterface: gnssSvStatusCb: b: input
 svInfo.flags is 8
09-19 02:24:29.477  1805  2283 E GnssHAL_GnssInterface: gnssSvStatusCb: a: input

Steps to reproduce

  1. Install & Run the app
  2. Auto crash's

On Device, I did encounter an issue as well upon trying to resume with your example, which the canvas is gone. I believe this is highly related with the issue https://github.com/NativeScript/canvas/issues/41

Example of error, which iterates forever

JS: GLContext: Cannot swap buffers!

Steps to reproduce

  1. Go in app
  2. Suspended the app
  3. Go back in
  4. Canvas is gone

I've tried upon Application resume to rebuild by using onReady method to reinitialize it as the below example

    Application.android.on("resume", () => {
      this.onReady();
    })

Looking forward to hearing from you

Best regards, Cheers

triniwiz commented 3 years ago

Using {N} 8.1 should help with the resume issue

red-game-dev commented 3 years ago

Using {N} 8.1 should help with the resume issue

Indeed it did help to upgrade to 8.1 version for resume issue! Thanks for your suggested fix :)

Regards to the other issue of emulator, hopefully it can be fixed as well soon. I'll let you know in case I will encounter any other issue related on this thread, if not related will be on separate thread! 💯

Looking forward to hearing from you

Best regards, Cheers

triniwiz commented 3 years ago

As for the emulator I will need to run some tests since I use both emulators and real devices to test

triniwiz commented 2 years ago

Can you try with the latest , please reopen if the issue still persists