当使用致命信号11(SIGSEGV)代码1加载MobileNet模型时,Cordova应用程序崩溃

时间:2019-04-07 16:17:31

标签: javascript android cordova tensorflow.js

我正在使用Tensorflow.js中的Cordova和MobileNet模型构建具有图像分类的Android应用。当我尝试在Android模拟器中运行该应用程序时,它会崩溃。

在浏览器中,一切正常,错误仅在移动应用中发生。 运行adb logcat会显示以下错误日志:

04-07 20:34:53.474  1601  1628 I PackageManager.DexOptimizer: Running dexopt (dexoptNeeded=1) on: /data/app/com.symmetronic.my_app-fgx4zlCfsFMQ5yubqXFbNw==/base.apk pkg=com.symmetronic.my_app isa=x86 dexoptFlags=boot_complete,debuggable,public target-filter=quicken oatDir=/data/app/com.symmetronic.my_app-fgx4zlCfsFMQ5yubqXFbNw==/oat sharedLibraries=PCL[]
04-07 20:34:53.488  6205  6205 W dex2oat : /system/bin/dex2oat --zip-fd=8 --zip-location=base.apk --input-vdex-fd=-1 --output-vdex-fd=10 --oat-fd=9 --oat-location=/data/app/com.symmetronic.my_app-fgx4zlCfsFMQ5yubqXFbNw==/oat/x86/base.odex --instruction-set=x86 --instruction-set-variant=x86 --instruction-set-features=default --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=quicken --swap-fd=11 --debuggable --classpath-dir=/data/app/com.symmetronic.my_app-fgx4zlCfsFMQ5yubqXFbNw== --class-loader-context=PCL[]
04-07 20:34:53.488  6205  6205 I dex2oat : /system/bin/dex2oat --input-vdex-fd=-1 --output-vdex-fd=10 --compiler-filter=quicken --debuggable --classpath-dir=/data/app/com.symmetronic.my_app-fgx4zlCfsFMQ5yubqXFbNw== --class-loader-context=PCL[]
04-07 20:34:54.625  1601  1615 I ActivityManager: Force stopping com.symmetronic.my_app appid=10080 user=-1: installPackageLI
04-07 20:34:54.694  1601  1628 I PackageManager: Package com.symmetronic.my_app codePath changed from /data/app/com.symmetronic.my_app-8aFO9XiwVEaUyCwWrbFFkg== to /data/app/com.symmetronic.my_app-fgx4zlCfsFMQ5yubqXFbNw==; Retaining data and using new
04-07 20:34:54.694  1601  1628 W PackageManager: Code path for com.symmetronic.my_app changing from /data/app/com.symmetronic.my_app-8aFO9XiwVEaUyCwWrbFFkg== to /data/app/com.symmetronic.my_app-fgx4zlCfsFMQ5yubqXFbNw==
04-07 20:34:54.694  1601  1628 W PackageManager: Resource path for com.symmetronic.my_app changing from /data/app/com.symmetronic.my_app-8aFO9XiwVEaUyCwWrbFFkg== to /data/app/com.symmetronic.my_app-fgx4zlCfsFMQ5yubqXFbNw==
04-07 20:34:54.833  1601  1628 I ActivityManager: Force stopping com.symmetronic.my_app appid=10080 user=0: pkg removed
04-07 20:34:54.841  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.android.vending/com.google.android.finsky.packagemanager.impl.PackageMonitorReceiverImpl$RegisteredReceiver
04-07 20:34:54.865  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.android.vending/com.google.android.finsky.instantapps.appmanagement.InstantAppRemoveMonitor
04-07 20:34:54.865  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.gms/.games.chimera.GamesSystemBroadcastReceiverProxy
04-07 20:34:54.865  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.gms/.photos.autobackup.PhotosAppUninstalledReceiver
04-07 20:34:54.865  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
04-07 20:34:54.865  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.googlequicksearchbox/com.google.android.apps.gsa.googlequicksearchbox.GelStubAppWatcher
04-07 20:34:54.865  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.android.vending/com.google.android.finsky.packagemanager.impl.PackageMonitorReceiverImpl$RegisteredReceiver
04-07 20:34:54.865  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.gms/.games.chimera.GamesSystemBroadcastReceiverProxy
04-07 20:34:54.866  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.gms/.gass.chimera.PackageChangeBroadcastReceiver
04-07 20:34:54.866  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
04-07 20:34:54.866  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.googlequicksearchbox/com.google.android.apps.gsa.googlequicksearchbox.GelStubAppWatcher
04-07 20:34:54.866  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.apps.photos/.account.full.FetchAccountPropertiesAppUpgradeBroadcastReceiver
04-07 20:34:54.866  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.apps.photos/.account.full.SyncAccountsForLoginBroadcastReceiver
04-07 20:34:54.866  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.apps.photos/.experiments.phenotype.full.PhenotypeAppUpgradeBroadcastReceiver
04-07 20:34:54.866  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.apps.photos/.notificationchannels.AppUpdateBroadcastReceiver
04-07 20:34:54.867  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.gms/.gass.chimera.PackageChangeBroadcastReceiver
04-07 20:34:54.867  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
04-07 20:34:54.867  1601  1615 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:com.symmetronic.my_app flg=0x4000010 (has extras) } to com.google.android.googlequicksearchbox/com.google.android.apps.gsa.googlequicksearchbox.GelStubAppWatcher
04-07 20:34:54.897  2653  2653 I Finsky  : [2] ilh.run(4): Package state data is missing for com.symmetronic.my_app
04-07 20:34:55.025  1790  1790 D ImsResolver: maybeAddedImsService, packageName: com.symmetronic.my_app
04-07 20:34:55.088  2167  6227 I ChromeSync: [Sync,SyncIntentOperation] Handling the intent: Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.symmetronic.my_app flg=0x4000010 cmp=com.google.android.gms/.chimera.GmsIntentOperationService (has extras) }.
04-07 20:34:55.831  1601  2442 I ActivityManager: START u0 {act=android.intent.action.MAIN flg=0x10000000 cmp=com.symmetronic.my_app/.MainActivity} from uid 2000
04-07 20:34:55.859  1601  4017 I ActivityManager: Start proc 6272:com.symmetronic.my_app/u0a80 for activity com.symmetronic.my_app/.MainActivity
04-07 20:34:56.051  1705  1910 W asset   : Asset path /data/app/com.symmetronic.my_app-Fk3cAnvoyCLFObhs_4-Piw==/base.apk is neither a directory nor file (type=1).
04-07 20:34:56.051  1705  1910 E ResourcesManager: failed to add asset path /data/app/com.symmetronic.my_app-Fk3cAnvoyCLFObhs_4-Piw==/base.apk
04-07 20:34:56.051  1705  1910 W PackageManager: Failure retrieving resources for com.symmetronic.my_app
04-07 20:34:56.051  1705  1910 W asset   : Asset path /data/app/com.symmetronic.my_app-Fk3cAnvoyCLFObhs_4-Piw==/base.apk is neither a directory nor file (type=1).
04-07 20:34:56.052  1705  1910 E ResourcesManager: failed to add asset path /data/app/com.symmetronic.my_app-Fk3cAnvoyCLFObhs_4-Piw==/base.apk
04-07 20:34:56.052  1705  1910 W PackageManager: Failure retrieving resources for com.symmetronic.my_app
04-07 20:34:56.052  1705  1910 W asset   : Asset path /data/app/com.symmetronic.my_app-Fk3cAnvoyCLFObhs_4-Piw==/base.apk is neither a directory nor file (type=1).
04-07 20:34:56.052  1705  1910 E ResourcesManager: failed to add asset path /data/app/com.symmetronic.my_app-Fk3cAnvoyCLFObhs_4-Piw==/base.apk
04-07 20:34:56.052  1705  1910 W PackageManager: Failure retrieving resources for com.symmetronic.my_app
04-07 20:34:56.052  1705  1910 W asset   : Asset path /data/app/com.symmetronic.my_app-Fk3cAnvoyCLFObhs_4-Piw==/base.apk is neither a directory nor file (type=1).
04-07 20:34:56.052  1705  1910 E ResourcesManager: failed to add asset path /data/app/com.symmetronic.my_app-Fk3cAnvoyCLFObhs_4-Piw==/base.apk
04-07 20:34:56.052  1705  1910 W PackageManager: Failure retrieving resources for com.symmetronic.my_app
04-07 20:34:56.052  1705  1910 W asset   : Asset path /data/app/com.symmetronic.my_app-Fk3cAnvoyCLFObhs_4-Piw==/base.apk is neither a directory nor file (type=1).
04-07 20:34:56.052  1705  1910 E ResourcesManager: failed to add asset path /data/app/com.symmetronic.my_app-Fk3cAnvoyCLFObhs_4-Piw==/base.apk
04-07 20:34:56.052  1705  1910 W PackageManager: Failure retrieving resources for com.symmetronic.my_app
04-07 20:34:56.391  1601  4605 I ActivityManager: Start proc 6313:com.android.chrome:sandboxed_process0/u0i6 for webview_service com.symmetronic.my_app/org.chromium.content.app.SandboxedProcessService0
04-07 20:34:58.133  1601  1622 I ActivityManager: Displayed com.symmetronic.my_app/.MainActivity: +2s287ms
04-07 20:34:59.106  6272  6355 I chatty  : uid=10080(com.symmetronic.my_app) RenderThread identical 2 lines
04-07 20:34:59.782  6272  6355 I chatty  : uid=10080(com.symmetronic.my_app) RenderThread identical 4 lines
04-07 20:35:00.896  6272  6353 I chatty  : uid=10080(com.symmetronic.my_app) Chrome_InProcGp identical 2 lines
04-07 20:35:00.900  6272  6353 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 6353 (Chrome_InProcGp), pid 6272 (onic.my_app)
04-07 20:35:00.964  6430  6430 F DEBUG   : pid: 6272, tid: 6353, name: Chrome_InProcGp  >>> com.symmetronic.my_app <<<
04-07 20:35:01.625  1601  6432 W ActivityManager:   Force finishing activity com.symmetronic.my_app/.MainActivity
04-07 20:35:01.653  1601  1616 I ActivityManager: Showing crash dialog for package com.symmetronic.my_app u0

这是我的package.json的摘录:

{
  ...
  "dependencies": {
    "@tensorflow-models/mobilenet": "^1.0.0",
    "@tensorflow/tfjs": "^1.0.4",
    ...
  }
}

这是图像分类的相关部分:

import * as mobilenet from '@tensorflow-models/mobilenet';

let image = document.getElementById('my-image');

// The following lines lead to the app crash
mobilenet.load()
  .then(model => {
    return model.classify(image);
  })
  .then(predictions => {
    console.log(predictions);
  });

我希望图像分类能够像在浏览器中一样在模拟器中工作。

0 个答案:

没有答案