首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >嵌入式人行横道增加Android上的分配内存

嵌入式人行横道增加Android上的分配内存
EN

Stack Overflow用户
提问于 2016-02-18 03:41:11
回答 1查看 3K关注 0票数 3

我有一个多个web应用程序,我希望能够在一个本地android应用程序中运行一个webview。我目前正在嵌入一个人行横道浏览器,并在其中加载应用程序。它对一些web应用程序非常有用,但是随着web应用程序的增加,我会发现一些错误会使我的android应用程序崩溃。

我尝试过的事物:

  • Android:largeHeap=“真”--帮助我运行了更大的网络应用程序。
  • Android:hardwareAccelerated=“真”--帮助我获得了更好的表现。
  • 命令行=‘-忽略-gpu-黑名单’中的资产/xwalk命令行-也有帮助。

仍然有一些web应用程序(通过统一创建)要求我在为桌面测试创建它们时分配大约1Gb。我将在最新的手机上使用这个android应用程序,并且可以使用如此高的内存使用量。

如果我试图在桌面浏览器上打开这个应用程序,那么它就能工作,这就是我认为这是内存分配问题的原因。我使用的是人行横道17,它启用了webGL,并且较小的应用程序运行webgl非常好。

我有几个问题:

  1. 有没有办法迫使人行横道嵌入式浏览器为自己分配1GB内存。(我知道这会毁了我的设备,可能不是很好,但请原谅我)
  2. 我是否可以将应用程序的内存使用量扩展到largeHeap以外。如果是的话,怎么做?我需要这样做才能启用这样大的web应用程序吗?
  3. 有什么问题是我错过的,可能掩盖了这里的真正问题。
  4. 我知道这种类型的应用程序只会在最新的手机上运行。对于内存使用率如此高的应用程序来说,有什么影响呢?
  5. 我还有没有其他途径可以让我在android应用程序中运行大型的web应用程序呢?

这里是堆栈溢出用户常见问题的答案:)

Xml:

代码语言:javascript
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.mycompany.myproject.webapplicationActivity">


    <org.xwalk.core.XWalkView
        android:id="@+id/xwalkWebView"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#000000"
        />    
</RelativeLayout>

Activity:

代码语言:javascript
复制
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webapplicationActivity);

    xWalkWebView=(XWalkView)findViewById(R.id.xwalkWebView);

    // turn on debugging
    XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
    xWalkWebView.setKeepScreenOn(true);
    xWalkWebView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
    String urlToBeLoaded = "http://www.google.com";

    Bundle bundle = getIntent().getExtras();
    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if(extras == null) {
            Log.i(TAG,"error in reading extras");
        } else {
            urlToBeLoaded = extras.getString("url");
        }
    }
    xWalkWebView.load(urlToBeLoaded, null);

权限

*人行横道需要很多这样的东西,我正在用剩下的。但也许那里有冲突。

代码语言:javascript
复制
 <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

ADB logcat

代码语言:javascript
复制
GL  : validate_display:255 error 3008 (EGL_BAD_DISPLAY)
02-17 18:11:55.862 23023 23023 W art     : Attempt to remove non-JNI local reference, dumping thread
02-17 18:11:55.903  4335  4448 I ActivityManager: Displayed com.mycompany.myProject/.GamePlayActivity: +464ms
02-17 18:11:55.904 23023 23023 W cr.BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 23023
02-17 18:11:55.904 22463 22463 I Keyboard.Facilitator: onFinishInput()
02-17 18:11:55.931 23023 23023 E chromium: [ERROR:layer_tree_host_impl.cc(2121)] Forcing zero-copy tile initialization as worker context is missing
02-17 18:11:55.980  4335  4448 I WindowManager: Screen frozen for +541ms due to Window{f87dd7b u0 com.mycompany.myProject/com.mycompany.myProject.GamePlayActivity}
02-17 18:11:57.987  4335  4448 I art     : Starting a blocking GC Explicit
02-17 18:11:58.205  4335  4448 I art     : Explicit concurrent mark sweep GC freed 12393(780KB) AllocSpace objects, 5(100KB) LOS objects, 23% free, 52MB/68MB, paused 1.298ms total 216.765ms
02-17 18:11:58.206  4335 15896 W InputMethodManagerService: Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@3b6394f attribute=null, token = android.os.BinderProxy@d44f10a
02-17 18:11:58.726 23023 23023 I chromium: [INFO:CONSOLE(1)] "Decompressed Release/StuntRunner_WebGL.memgz in 254ms. You can remove this delay if you configure your web server to host files using gzip compression.", source: https://<source>/Release/UnityLoader.js (1)
02-17 18:11:59.103 22037 22037 I ServiceManager: Waiting for service AtCmdFwd...
02-17 18:11:59.663 23023 23023 I chromium: [INFO:CONSOLE(1)] "Decompressed Release/StuntRunner_WebGL.jsgz in 853ms. You can remove this delay if you configure your web server to host files using gzip compression.", source: https://<source>/Release/UnityLoader.js (1)
02-17 18:11:59.985 23023 23023 I chromium: [INFO:CONSOLE(1)] "optimizing out Math.fround calls", source: https://<source>/Release/UnityLoader.js (1)
02-17 18:12:00.103 22037 22037 I ServiceManager: Waiting for service AtCmdFwd...
02-17 18:12:01.104 22037 22037 I ServiceManager: Waiting for service AtCmdFwd...
02-17 18:12:02.105 22037 22037 I ServiceManager: Waiting for service AtCmdFwd...
02-17 18:12:03.105 22037 22037 I ServiceManager: Waiting for service AtCmdFwd...
02-17 18:12:03.174  4335 22386 D NetlinkSocketObserver: NeighborEvent{elapsedMs=775340136, 192.168.1.1, [100D7F6DFA6E], RTM_NEWNEIGH, NUD_REACHABLE}
02-17 18:12:04.106 22037 22037 W Atfwd_Sendcmd: AtCmdFwd service not published, waiting... retryCnt : 5
02-17 18:12:10.387  4335  6452 D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ id=842, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ], android.os.BinderProxy@82c1e86)
02-17 18:12:10.392  4335  6549 I ActivityManager: Process com.instagram.android (pid 14465) has died
02-17 18:12:10.409  4335  5621 D ConnectivityService: releasing NetworkRequest NetworkRequest [ id=842, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
02-17 18:12:10.504  4335  5621 E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ id=842, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
02-17 18:12:10.781 23023 23263 F libc    : Fatal signal 4 (SIGILL), code 1, fault addr 0xd3781358 in tid 23263 (Chrome_InProcRe)
02-17 18:12:10.886  3293  3293 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-17 18:12:10.887  3293  3293 F DEBUG   : Build fingerprint: 'google/angler/angler:6.0.1/MMB29P/2473553:user/release-keys'
02-17 18:12:10.887  3293  3293 F DEBUG   : Revision: '0'
02-17 18:12:10.887  3293  3293 F DEBUG   : ABI: 'arm'
02-17 18:12:10.887  3293  3293 F DEBUG   : pid: 23023, tid: 23263, name: Chrome_InProcRe  >>> com.mycompany.myProject <<<
02-17 18:12:10.887  3293  3293 F DEBUG   : signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 0xd3781358
02-17 18:12:10.933  3293  3293 F DEBUG   :     r0 d5366044  r1 40005000  r2 0855d000  r3 02182000
02-17 18:12:10.933  3293  3293 F DEBUG   :     r4 d5366044  r5 40000000  r6 00000000  r7 00000000
02-17 18:12:10.933  3293  3293 F DEBUG   :     r8 40005000  r9 d66d4050  sl 40000000  fp d66bee10
02-17 18:12:10.934  3293  3293 F DEBUG   :     ip f70ff624  sp d66bed40  lr d3dfa5e1  pc d3781358  cpsr 80030030
02-17 18:12:10.938  3293  3293 F DEBUG   : 
02-17 18:12:10.938  3293  3293 F DEBUG   : backtrace:
02-17 18:12:10.926  3293  3293 W debuggerd: type=1400 audit(0.0:9681): avc: denied { read } for name="kgsl-3d0" dev="tmpfs" ino=1150 scontext=u:r:debuggerd:s0 tcontext=u:object_r:gpu_device:s0 tclass=chr_file permissive=0
02-17 18:12:10.938  3293  3293 F DEBUG   :     #00 pc 001e3358  /data/app/com.mycompany.myProject-1/lib/arm/libxwalkcore.so
02-17 18:12:10.938  3293  3293 F DEBUG   :     #01 pc 0085c5dd  /data/app/com.mycompany.myProject-1/lib/arm/libxwalkcore.so
02-17 18:12:11.276  3293  3293 W debuggerd: type=1400 audit(0.0:9682): avc: denied { read } for name="kgsl-3d0" dev="tmpfs" ino=1150 scontext=u:r:debuggerd:s0 tcontext=u:object_r:gpu_device:s0 tclass=chr_file permissive=0
02-17 18:12:11.817  4335 23497 W ActivityManager:   Force finishing activity com.mycompany.myProject/.GamePlayActivity
02-17 18:12:11.818  3293  3293 F DEBUG   : 
02-17 18:12:11.818  3293  3293 F DEBUG   : Tombstone written to: /data/tombstones/tombstone_05
02-17 18:12:11.818  3293  3293 E DEBUG   : AM write failed: Broken pipe
02-17 18:12:11.890  4335 22149 I OpenGLRenderer: Initialized EGL, version 1.4
02-17 18:12:11.987  4335  5717 D GraphicsStats: Buffer count: 4
02-17 18:12:11.989  4335  5980 I WindowState: WIN DEATH: Window{def3a97 u0 com.mycompany.myProject/com.mycompany.myProject.LibraryActivity}
02-17 18:12:11.994  4335  5709 I WindowState: WIN DEATH: Window{9ffe3af u0 com.mycompany.myProject/com.mycompany.myProject.LoginActivity}
02-17 18:12:11.996  4335  4351 I WindowState: WIN DEATH: Window{ee84425 u0 com.mycompany.myProject/com.mycompany.myProject.GameDescriptionActivity}
02-17 18:12:11.999  4335  7252 I WindowState: WIN DEATH: Window{a09b55b u0 SurfaceView}
02-17 18:12:12.001  4335  5717 I WindowState: WIN DEATH: Window{f87dd7b u0 com.mycompany.myProject/com.mycompany.myProject.GamePlayActivity}
02-17 18:12:12.022  3309  3309 I Zygote  : Process 23023 exited due to signal (4)
02-17 18:12:12.024  4335 28075 I ActivityManager: Process com.mycompany.myProject (pid 23023) has died
02-17 18:12:12.073  4335 28075 I ActivityManager: Start proc 23507:com.mycompany.myProject/u0a179 for activity com.mycompany.myProject/.GameDescriptionActivity
02-17 18:12:12.076 23507 23507 I art     : Late-enabling -Xcheck:jni

提前谢谢你!

EN

回答 1

Stack Overflow用户

发布于 2019-02-16 07:00:15

我有过这样的问题。我认为这个问题是伴随着像adsense这样的广告,或者是一些JavaScript出了问题。

试一试

代码语言:javascript
复制
 xwalk Release 'org.xwalk:xwalk_core_library:21.51.546.7'

我希望这对你有帮助

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35472398

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档