Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating UI from webview's Javascript Interface crashes the app
    text
    copied!<p>I'm working on a hybrid webview/native app and am running into an issue where the app crashes.</p> <p>Here's the quick rundown:</p> <ul> <li>app is in a single FrameLayout</li> <li>the top has a LinearLayout where I place a button to on the left &amp; right sides and my app's logo in the middle &amp; below that I have my WebView</li> <li>I'm using <code>webview.addJavascriptInterface(myObj, "myJsName")</code> to attach a JS interface to the web view</li> <li>in the webView I load a simple HTML page that calls public methods in my JS interface. These methods just show or hide the various View in the faux "title bar" (the LineadLayout)</li> <li>the methods in my JS interface are called just fine - but if i try to update the UI in those calls the app crashes with a <code>Fatal signal 11 (SIGSEGV)</code> </li> </ul> <p>Here's the relevant code from my activity:</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); webview = (WebView) findViewById(R.id.webview); logo = (ImageView) findViewById(R.id.logo); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setLightTouchEnabled(true); webview.getSettings().setEnableSmoothTransition(true); javascriptInterface = new JavascriptInterface() { public void showLogo() { runOnUiThread(new Runnable() { public void run() { MyActivity.this.logo.setVisibility(View.VISIBLE); } }); } public void hideLogo() { MyActivity.this.runOnUiThread( new Runnable() { public void run() { MyActivity.this.logo.setVisibility(View.GONE); } }); } }; webview.addJavascriptInterface(javascriptInterface, JavascriptInterface.NAME); webview.loadUrl("file:///android_asset/test.html"); } </code></pre> <ul> <li>When calling <code>hideLogo()</code> from my JS code the app crashes with <code>Fatal signal 11 (SIGSEGV)</code>. </li> <li>if i remove the <code>MyActivity.this.runOnUiThread</code> and just try to modify the UI nothing happens (no crash either)</li> <li>when debugging I have assured that the <code>logo</code> variable is not null and indeed represents the correct ImageView</li> <li>also, upon calling <code>hideLogo()</code> the logo does disappear right before the app crashes</li> </ul> <p>So, now I'm really confused. I've tried using a <code>Handler</code> and an <code>AsycTask</code> &amp; both give me the same type of crash.</p> <p>I'm super new to Android so I'm hoping I'm doing something stupid here. Any and all help is appreciated!</p> <p><em>update here's verbose output from log cat</em></p> <pre><code>10-01 12:29:55.591: INFO/Choreographer(10074): Skipped 74 frames! The application may be doing too much work on its main thread. 10-01 12:29:55.622: null/libc(10074): Fatal signal 11 (SIGSEGV) at 0x00000008 (code=1), thread 10074 (com.arin.test) 10-01 12:29:55.724: INFO/DEBUG(121): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 10-01 12:29:55.724: INFO/DEBUG(121): Build fingerprint: 'google/takju/maguro:4.1.1/JRO03C/398337:user/release-keys' 10-01 12:29:55.724: INFO/DEBUG(121): pid: 10074, tid: 10074, name: com.arin.test &gt;&gt;&gt; com.arin.test &lt;&lt;&lt; 10-01 12:29:55.724: INFO/DEBUG(121): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000008 10-01 12:29:55.849: INFO/DEBUG(121): r0 00000008 r1 5bc3ebc0 r2 00000010 r3 00000004 10-01 12:29:55.849: INFO/DEBUG(121): r4 5a52d008 r5 5a52de38 r6 00000001 r7 00000004 10-01 12:29:55.849: INFO/DEBUG(121): r8 00000008 r9 00000001 sl 00000004 fp 00000001 10-01 12:29:55.849: INFO/DEBUG(121): ip 00000001 sp bedb2310 lr 5bea188c pc 5beca774 cpsr 80000010 10-01 12:29:55.849: INFO/DEBUG(121): d0 00000000bd0d3d00 d1 3f8469ee00000000 10-01 12:29:55.849: INFO/DEBUG(121): d2 0000000000000080 d3 000000000000003f 10-01 12:29:55.849: INFO/DEBUG(121): d4 0000000000000000 d5 000000003f800000 10-01 12:29:55.849: INFO/DEBUG(121): d6 3f8469eebd0d3dcb d7 3f8000003f800000 10-01 12:29:55.849: INFO/DEBUG(121): d8 bf800000bf800000 d9 0000000000000000 10-01 12:29:55.849: INFO/DEBUG(121): d10 0000000000000000 d11 0000000000000000 10-01 12:29:55.849: INFO/DEBUG(121): d12 0000000000000000 d13 0000000000000000 10-01 12:29:55.849: INFO/DEBUG(121): d14 0000000000000000 d15 0000000000000000 10-01 12:29:55.849: INFO/DEBUG(121): d16 0000000000000008 d17 000000c1417d8568 10-01 12:29:55.849: INFO/DEBUG(121): d18 000000000358b208 d19 0000000000000000 10-01 12:29:55.849: INFO/DEBUG(121): d20 0000000000000000 d21 0000000000000000 10-01 12:29:55.849: INFO/DEBUG(121): d22 0000000000000000 d23 0000000000000000 10-01 12:29:55.849: INFO/DEBUG(121): d24 3fee45a1e2e00000 d25 4000000006800000 10-01 12:29:55.849: INFO/DEBUG(121): d26 0000000000000000 d27 0000000000000000 10-01 12:29:55.849: INFO/DEBUG(121): d28 408d900000000000 d29 0000000000000000 10-01 12:29:55.849: INFO/DEBUG(121): d30 bffffffff8a00000 d31 0000000000000000 10-01 12:29:55.849: INFO/DEBUG(121): scr 20000010 10-01 12:29:55.849: INFO/DEBUG(121): backtrace: 10-01 12:29:55.849: INFO/DEBUG(121): #00 pc 00034774 /system/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so 10-01 12:29:55.849: INFO/DEBUG(121): #01 pc 0000b888 /system/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so 10-01 12:29:55.849: INFO/DEBUG(121): stack: 10-01 12:29:55.849: INFO/DEBUG(121): bedb22d0 03d00000 10-01 12:29:55.849: INFO/DEBUG(121): bedb22d4 00000000 10-01 12:29:55.849: INFO/DEBUG(121): bedb22d8 5a4defc8 10-01 12:29:55.849: INFO/DEBUG(121): bedb22dc 5a5316c0 10-01 12:29:55.849: INFO/DEBUG(121): bedb22e0 5a52dee4 10-01 12:29:55.849: INFO/DEBUG(121): bedb22e4 00000008 10-01 12:29:55.849: INFO/DEBUG(121): bedb22e8 00000002 10-01 12:29:55.849: INFO/DEBUG(121): bedb22ec 00000004 10-01 12:29:55.849: INFO/DEBUG(121): bedb22f0 5a52dee4 10-01 12:29:55.849: INFO/DEBUG(121): bedb22f4 5a52d008 10-01 12:29:55.849: INFO/DEBUG(121): bedb22f8 5a52de34 10-01 12:29:55.849: INFO/DEBUG(121): bedb22fc 00000000 10-01 12:29:55.849: INFO/DEBUG(121): bedb2300 00000004 10-01 12:29:55.849: INFO/DEBUG(121): bedb2304 00000023 10-01 12:29:55.849: INFO/DEBUG(121): bedb2308 df0027ad 10-01 12:29:55.849: INFO/DEBUG(121): bedb230c 00000000 10-01 12:29:55.849: INFO/DEBUG(121): #00 bedb2310 5a52d008 10-01 12:29:55.849: INFO/DEBUG(121): ........ ........ 10-01 12:29:55.849: INFO/DEBUG(121): #01 bedb2310 5a52d008 10-01 12:29:55.849: INFO/DEBUG(121): bedb2314 5bea188c /system/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so 10-01 12:29:55.849: INFO/DEBUG(121): bedb2318 5a52d008 10-01 12:29:55.849: INFO/DEBUG(121): bedb231c 00000004 10-01 12:29:55.849: INFO/DEBUG(121): bedb2320 00000004 10-01 12:29:55.849: INFO/DEBUG(121): bedb2324 00000000 10-01 12:29:55.849: INFO/DEBUG(121): bedb2328 00000005 10-01 12:29:55.849: INFO/DEBUG(121): bedb232c 5bea398c /system/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so 10-01 12:29:55.849: INFO/DEBUG(121): bedb2330 5a52d008 10-01 12:29:55.849: INFO/DEBUG(121): bedb2334 00000004 10-01 12:29:55.849: INFO/DEBUG(121): bedb2338 00000000 10-01 12:29:55.849: INFO/DEBUG(121): bedb233c 5bef106c /system/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so 10-01 12:29:55.849: INFO/DEBUG(121): bedb2340 00000005 10-01 12:29:55.849: INFO/DEBUG(121): bedb2344 5bea4a70 /system/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so (glDrawArrays+804) 10-01 12:29:55.849: INFO/DEBUG(121): bedb2348 00000004 10-01 12:29:55.849: INFO/DEBUG(121): bedb234c 00000000 10-01 12:29:55.849: INFO/DEBUG(121): memory near r1: 10-01 12:29:55.849: INFO/DEBUG(121): 5bc3eba0 ffffffff ffffffff ffffffff ffffffff ................ 10-01 12:29:55.849: INFO/DEBUG(121): 5bc3ebb0 ffffffff ffffffff ffffffff ffffffff ................ 10-01 12:29:55.849: INFO/DEBUG(121): 5bc3ebc0 ffffffff ffffffff ffffffff ffffffff ................ 10-01 12:29:55.849: INFO/DEBUG(121): 5bc3ebd0 ffffffff ffffffff ffffffff ffffffff ................ 10-01 12:29:55.849: INFO/DEBUG(121): 5bc3ebe0 ffffffff ffffffff ffffffff ffffffff ................ 10-01 12:29:55.849: INFO/DEBUG(121): memory near r4: 10-01 12:29:55.849: INFO/DEBUG(121): 5a52cfe8 5a525fe0 00000001 00000000 00000007 ._RZ............ 10-01 12:29:55.849: INFO/DEBUG(121): 5a52cff8 00000007 00000007 00000000 00000f9b ................ 10-01 12:29:55.849: INFO/DEBUG(121): 5a52d008 00000018 0000e7f4 00001c80 00001100 ................ 10-01 12:29:55.849: INFO/DEBUG(121): 5a52d018 00001100 0000000a 00000428 00000048 ........(...H... 10-01 12:29:55.849: INFO/DEBUG(121): 5a52d028 0000003c 00000048 0000003c 00000004 &lt;...H...&lt;....... 10-01 12:29:55.849: INFO/DEBUG(121): memory near r5: 10-01 12:29:55.849: INFO/DEBUG(121): 5a52de18 00000000 00000000 00000000 00000000 ................ 10-01 12:29:55.849: INFO/DEBUG(121): 5a52de28 00000000 00000000 5a52dc0c 5a52dcb4 ..........RZ..RZ 10-01 12:29:55.849: INFO/DEBUG(121): 5a52de38 5a52dce4 00000000 00000000 00000000 ..RZ............ 10-01 12:29:55.849: INFO/DEBUG(121): 5a52de48 00000000 00000000 00000000 00000000 ................ 10-01 12:29:55.849: INFO/DEBUG(121): 5a52de58 00000002 00000003 00000003 00000004 ................ 10-01 12:29:55.849: INFO/DEBUG(121): memory near sp: 10-01 12:29:55.849: INFO/DEBUG(121): bedb22f0 5a52dee4 5a52d008 5a52de34 00000000 ..RZ..RZ4.RZ.... 10-01 12:29:55.849: INFO/DEBUG(121): bedb2300 00000004 00000023 df0027ad 00000000 ....#....'...... 10-01 12:29:55.849: INFO/DEBUG(121): bedb2310 5a52d008 5bea188c 5a52d008 00000004 ..RZ...[..RZ.... 10-01 12:29:55.849: INFO/DEBUG(121): bedb2320 00000004 00000000 00000005 5bea398c .............9.[ 10-01 12:29:55.849: INFO/DEBUG(121): bedb2330 5a52d008 00000004 00000000 5bef106c ..RZ........l..[ 10-01 12:29:55.849: INFO/DEBUG(121): code around pc: 10-01 12:29:55.849: INFO/DEBUG(121): 5beca754 e781410c e28cc001 e15c0003 3afffffa .A........\....: 10-01 12:29:55.849: INFO/DEBUG(121): 5beca764 e8bd8010 e92d4010 e3a0c000 ea000004 .....@-......... 10-01 12:29:55.849: INFO/DEBUG(121): 5beca774 e5904000 e5014008 e5904004 e0800002 .@...@...@...... 10-01 12:29:55.849: INFO/DEBUG(121): 5beca784 e5014004 e15c0003 e2811008 e28cc001 .@....\......... 10-01 12:29:55.849: INFO/DEBUG(121): 5beca794 3afffff6 e8bd8010 e92d4010 e3a0c000 ...:.....@-..... 10-01 12:29:55.856: INFO/DEBUG(121): code around lr: 10-01 12:29:55.856: INFO/DEBUG(121): 5bea186c e3530000 1a000005 e1a03007 e59c0018 ..S......0...... 10-01 12:29:55.856: INFO/DEBUG(121): 5bea187c e59c101c e59c2014 e1a0e00f e59cf024 ..... ......$... 10-01 12:29:55.856: INFO/DEBUG(121): 5bea188c e2866001 e2855004 e5942e50 e3a03001 .`...P..P....0.. 10-01 12:29:55.856: INFO/DEBUG(121): 5bea189c e1560002 3affffeb e2840eed e1a01008 ..V....:........ 10-01 12:29:55.856: INFO/DEBUG(121): 5bea18ac e280000c e1a02003 e8bd41f0 eaffe178 ..... ...A..x... 10-01 12:29:56.060: INFO/WindowState(321): WIN DEATH: Window{425993f8 com.arin.test/com.arin.test paused=false} 10-01 12:29:56.060: INFO/ActivityManager(321): Process com.arin.test (pid 10074) has died. 10-01 12:29:56.060: WARN/ActivityManager(321): Force removing ActivityRecord{4226e5d0 com.arin.test/com.arin.test}: app died, no saved state 10-01 12:29:56.099: DEBUG/Zygote(124): Process 10074 terminated by signal (11) 10-01 12:29:56.161: WARN/InputMethodManagerService(321): Got RemoteException sending setActive(false) notification to pid 10074 uid 10008 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload