Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15770] Android: When Facebook autorize, App crashed on Android 4.4 kitkat.

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-11-27T18:50:51.000+0000
Affected Version/sRelease 3.1.3
Fix Version/s2013 Sprint 24, 2013 Sprint 24 API, Release 3.2.0, Release 3.3.0
ComponentsAndroid
LabelsSupportTeam, module_api, qe-testadded
ReporterJong Eun Lee
AssigneePing Wang
Created2013-11-14T07:48:26.000+0000
Updated2014-07-31T06:39:51.000+0000

Description

When Facebook autorize, App crashed on Android 4.4 kitkat. On Nexus 4 with android 4.3, it works properly. Pleas put your facebook app id before below test code.
var fb = require('facebook');
fb.appid = "YOUR_FACEBOOK_APP_ID";
fb.authorize();

Comments

  1. Mauro Parra-Miranda 2013-11-15

    Hello! Can you please provide a crashlog? Use DDMS or similar. Best, Mauro
  2. Jong Eun Lee 2013-11-18

    Is this enough? Best, Jong.
       [ERROR][TiApplication( 1803)] (main) [25792,34707] Sending event: exception on thread: main msg:java.lang.IllegalStateException: Calling View methods on another thread than the UI thread.; Titanium 3.1.3,2013/09/18 12:01,222f4d1
       [ERROR][TiApplication( 1803)] java.lang.IllegalStateException: Calling View methods on another thread than the UI thread.
       [ERROR][TiApplication( 1803)] 	at com.android.webview.chromium.WebViewChromium.createThreadException(WebViewChromium.java:268)
       [ERROR][TiApplication( 1803)] 	at com.android.webview.chromium.WebViewChromium.checkThread(WebViewChromium.java:284)
       [ERROR][TiApplication( 1803)] 	at com.android.webview.chromium.WebViewChromium.setLayoutParams(WebViewChromium.java:1618)
       [ERROR][TiApplication( 1803)] 	at android.webkit.WebView.setLayoutParams(WebView.java:2099)
       [ERROR][TiApplication( 1803)] 	at com.facebook.widget.WebDialog.setUpWebView(WebDialog.java:299)
       [ERROR][TiApplication( 1803)] 	at com.facebook.widget.WebDialog.onCreate(WebDialog.java:233)
       [ERROR][TiApplication( 1803)] 	at android.app.Dialog.dispatchOnCreate(Dialog.java:361)
       [ERROR][TiApplication( 1803)] 	at android.app.Dialog.show(Dialog.java:262)
       [ERROR][TiApplication( 1803)] 	at com.facebook.AuthorizationClient$WebViewAuthHandler.tryAuthorize(AuthorizationClient.java:482)
       [ERROR][TiApplication( 1803)] 	at com.facebook.AuthorizationClient.tryCurrentHandler(AuthorizationClient.java:230)
       [ERROR][TiApplication( 1803)] 	at com.facebook.AuthorizationClient.tryNextHandler(AuthorizationClient.java:209)
       [ERROR][TiApplication( 1803)] 	at com.facebook.AuthorizationClient.authorize(AuthorizationClient.java:133)
       [ERROR][TiApplication( 1803)] 	at com.facebook.AuthorizationClient.startOrContinueAuth(AuthorizationClient.java:114)
       [ERROR][TiApplication( 1803)] 	at com.facebook.Session.tryLegacyAuth(Session.java:1156)
       [ERROR][TiApplication( 1803)] 	at com.facebook.Session.authorize(Session.java:953)
       [ERROR][TiApplication( 1803)] 	at com.facebook.Session.open(Session.java:1017)
       [ERROR][TiApplication( 1803)] 	at com.facebook.Session.openForRead(Session.java:431)
       [ERROR][TiApplication( 1803)] 	at com.facebook.android.Facebook.openSession(Facebook.java:397)
       [ERROR][TiApplication( 1803)] 	at com.facebook.android.Facebook.authorize(Facebook.java:389)
       [ERROR][TiApplication( 1803)] 	at facebook.FacebookModule.executeAuthorize(FacebookModule.java:415)
       [ERROR][TiApplication( 1803)] 	at facebook.FacebookModule$1.onCurrentActivityReady(FacebookModule.java:226)
       [ERROR][TiApplication( 1803)] 	at org.appcelerator.titanium.util.TiUIHelper.waitForCurrentActivity(TiUIHelper.java:174)
       [ERROR][TiApplication( 1803)] 	at facebook.FacebookModule.authorize(FacebookModule.java:222)
       [ERROR][TiApplication( 1803)] 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
       [ERROR][TiApplication( 1803)] 	at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:64)
       [ERROR][TiApplication( 1803)] 	at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:861)
       [ERROR][TiApplication( 1803)] 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1084)
       [ERROR][TiApplication( 1803)] 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:316)
       [ERROR][TiApplication( 1803)] 	at android.os.Handler.dispatchMessage(Handler.java:98)
       [ERROR][TiApplication( 1803)] 	at android.os.Looper.loop(Looper.java:137)
       [ERROR][TiApplication( 1803)] 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
       [ERROR][AndroidRuntime( 1803)] FATAL EXCEPTION: main
       [ERROR][AndroidRuntime( 1803)] Process: com.testapp.facebook, PID: 1803
       [ERROR][AndroidRuntime( 1803)] java.lang.IllegalStateException: Calling View methods on another thread than the UI thread.
       [ERROR][AndroidRuntime( 1803)] 	at com.android.webview.chromium.WebViewChromium.createThreadException(WebViewChromium.java:268)
       [ERROR][AndroidRuntime( 1803)] 	at com.android.webview.chromium.WebViewChromium.checkThread(WebViewChromium.java:284)
       [ERROR][AndroidRuntime( 1803)] 	at com.android.webview.chromium.WebViewChromium.setLayoutParams(WebViewChromium.java:1618)
       [ERROR][AndroidRuntime( 1803)] 	at android.webkit.WebView.setLayoutParams(WebView.java:2099)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.widget.WebDialog.setUpWebView(WebDialog.java:299)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.widget.WebDialog.onCreate(WebDialog.java:233)
       [ERROR][AndroidRuntime( 1803)] 	at android.app.Dialog.dispatchOnCreate(Dialog.java:361)
       [ERROR][AndroidRuntime( 1803)] 	at android.app.Dialog.show(Dialog.java:262)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.AuthorizationClient$WebViewAuthHandler.tryAuthorize(AuthorizationClient.java:482)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.AuthorizationClient.tryCurrentHandler(AuthorizationClient.java:230)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.AuthorizationClient.tryNextHandler(AuthorizationClient.java:209)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.AuthorizationClient.authorize(AuthorizationClient.java:133)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.AuthorizationClient.startOrContinueAuth(AuthorizationClient.java:114)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.Session.tryLegacyAuth(Session.java:1156)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.Session.authorize(Session.java:953)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.Session.open(Session.java:1017)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.Session.openForRead(Session.java:431)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.android.Facebook.openSession(Facebook.java:397)
       [ERROR][AndroidRuntime( 1803)] 	at com.facebook.android.Facebook.authorize(Facebook.java:389)
       [ERROR][AndroidRuntime( 1803)] 	at facebook.FacebookModule.executeAuthorize(FacebookModule.java:415)
       [ERROR][AndroidRuntime( 1803)] 	at facebook.FacebookModule$1.onCurrentActivityReady(FacebookModule.java:226)
       [ERROR][AndroidRuntime( 1803)] 	at org.appcelerator.titanium.util.TiUIHelper.waitForCurrentActivity(TiUIHelper.java:174)
       [ERROR][AndroidRuntime( 1803)] 	at facebook.FacebookModule.authorize(FacebookModule.java:222)
       [ERROR][AndroidRuntime( 1803)] 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
       [ERROR][AndroidRuntime( 1803)] 	at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:64)
       [ERROR][AndroidRuntime( 1803)] 	at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:861)
       [ERROR][AndroidRuntime( 1803)] 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1084)
       [ERROR][AndroidRuntime( 1803)] 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:316)
       [ERROR][AndroidRuntime( 1803)] 	at android.os.Handler.dispatchMessage(Handler.java:98)
       [ERROR][AndroidRuntime( 1803)] 	at android.os.Looper.loop(Looper.java:137)
       [ERROR][AndroidRuntime( 1803)] 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
       [WARN][ActivityManager(  463)]   Force finishing activity com.oneamonth.bogoyo/org.appcelerator.titanium.TiActivity
       [ERROR][libEGL  (   53)] called unimplemented OpenGL ES API
       [ERROR][libEGL  (   53)] called unimplemented OpenGL ES API
       [ERROR][libEGL  (   53)] called unimplemented OpenGL ES API
       [ERROR][libEGL  (   53)] called unimplemented OpenGL ES API
       [ERROR][SurfaceFlinger(   53)] glCheckFramebufferStatusOES error -1619931597
       [ERROR][SurfaceFlinger(   53)] got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot
       [ERROR][libEGL  (   53)] called unimplemented OpenGL ES API
       [ERROR][libEGL  (   53)] called unimplemented OpenGL ES API
       
  3. Lokesh Choudhary 2013-11-22

    Tested the code below on build 3.2.0.v20131119142443
       var fb = require('facebook');
       fb.appid = 'YOUR FACEBOOK APPID';
       fb.permissions = ['publish_stream', 'read_stream']; // Permissions your app needs
       fb.forceDialogAuth = true;
       
       var win = Ti.UI.createWindow({
       	backgroundColor:'white'
       });
       
       var but = Ti.UI.createButton({
       	title:'authorize',
       	top:50
       });
       
       but.addEventListener('click',function(e){
       fb.addEventListener('login', function(e) {
           if (e.success) {
               alert('Logged In');
           } else if (e.error) {
               alert(e.error);
           } else if (e.cancelled) {
               alert("Canceled");
           }
       });
       fb.authorize();
       });
       
       var but1 = Ti.UI.createButton({
       	title:'Logout',
       	top:120 
       });
       
       but1.addEventListener('click',function(e){
       fb.addEventListener('logout', function(e) {
           alert('Logged out');
           
       });
       fb.logout();
       });
       
       win.add(but);
       win.add(but1);
       win.open();
       
    On android 4.4 device when I tap on the authorize button nothing happens & I cant tap on the authorize button again. On android 4.4 emulator for the same code I get a facebook login prompt.
  4. Lokesh Choudhary 2013-11-22

    On a nexus 4 running android 4.3, I get following errors:
       [ERROR] :  TiExceptionHandler: (main) [2413,2413] ----- Titanium Javascript Runtime Error -----
       [ERROR] :  TiExceptionHandler: (main) [0,2413] - In app.js:25,4
       [ERROR] :  TiExceptionHandler: (main) [0,2413] - Message: Uncaught Error: java.lang.Throwable: Warning: A WebView method was called on thread 'KrollRuntimeThread'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads.
       [ERROR] :  TiExceptionHandler: (main) [0,2413] - Source: fb.authorize();
       [ERROR] :  V8Exception: Exception occurred at app.js:25: Uncaught Error: java.lang.Throwable: Warning: A WebView method was called on thread 'KrollRuntimeThread'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads.
       
  5. Ping Wang 2013-11-26

    Tested with the latest master. 1. On Nexus7 (4.3): i) Ran the test app and got the same runtime error with last comment. ii) KS->MASHUPS->Facebook->Login/Logout works fine. 2. On 4.4 devices: i) If
       <android xmlns:android="http://schemas.android.com/apk/res/android">
               <manifest>
                   <application android:debuggable="true"/>
               </manifest>
       </android>
       
    is set in tiapp.xml, the test app works fine. Otherwise, it will not pop up the login web view as described in the above comment. ii) If
       <android xmlns:android="http://schemas.android.com/apk/res/android">
               <manifest>
               	<uses-sdk android:targetSdkVersion="11"/>
               </manifest>
       </android>
       
    is set in tiapp.xml, the test app crashes with log
       W/System.err(22724): 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
       E/AndroidRuntime(22724): FATAL EXCEPTION: main
       E/AndroidRuntime(22724): Process: com.appcelerator.timob15770, PID: 22724
       E/AndroidRuntime(22724): java.lang.IllegalStateException: Calling View methods on another thread than the UI thread.
       E/AndroidRuntime(22724): 	at com.android.webview.chromium.WebViewChromium.createThreadException(WebViewChromium.java:268)
       E/AndroidRuntime(22724): 	at com.android.webview.chromium.WebViewChromium.checkThread(WebViewChromium.java:284)
       E/AndroidRuntime(22724): 	at com.android.webview.chromium.WebViewChromium.setLayoutParams(WebViewChromium.java:1618)
       E/AndroidRuntime(22724): 	at android.webkit.WebView.setLayoutParams(WebView.java:2099)
       E/AndroidRuntime(22724): 	at com.facebook.widget.WebDialog.setUpWebView(WebDialog.java:299)
       E/AndroidRuntime(22724): 	at com.facebook.widget.WebDialog.onCreate(WebDialog.java:233)
       E/AndroidRuntime(22724): 	at android.app.Dialog.dispatchOnCreate(Dialog.java:361)
       E/AndroidRuntime(22724): 	at android.app.Dialog.show(Dialog.java:262)
       E/AndroidRuntime(22724): 	at com.facebook.AuthorizationClient$WebViewAuthHandler.tryAuthorize(AuthorizationClient.java:482)
       E/AndroidRuntime(22724): 	at com.facebook.AuthorizationClient.tryCurrentHandler(AuthorizationClient.java:230)
       E/AndroidRuntime(22724): 	at com.facebook.AuthorizationClient.tryNextHandler(AuthorizationClient.java:209)
       E/AndroidRuntime(22724): 	at com.facebook.AuthorizationClient.authorize(AuthorizationClient.java:133)
       E/AndroidRuntime(22724): 	at com.facebook.AuthorizationClient.startOrContinueAuth(AuthorizationClient.java:114)
       E/AndroidRuntime(22724): 	at com.facebook.Session.tryLegacyAuth(Session.java:1156)
       E/AndroidRuntime(22724): 	at com.facebook.Session.authorize(Session.java:953)
       E/AndroidRuntime(22724): 	at com.facebook.Session.open(Session.java:1017)
       E/AndroidRuntime(22724): 	at com.facebook.Session.openForPublish(Session.java:461)
       E/AndroidRuntime(22724): 	at com.facebook.android.Facebook.openSession(Facebook.java:395)
       E/AndroidRuntime(22724): 	at com.facebook.android.Facebook.authorize(Facebook.java:389)
       E/AndroidRuntime(22724): 	at facebook.FacebookModule.executeAuthorize(FacebookModule.java:415)
       E/AndroidRuntime(22724): 	at facebook.FacebookModule$1.onCurrentActivityReady(FacebookModule.java:226)
       E/AndroidRuntime(22724): 	at org.appcelerator.titanium.util.TiUIHelper.waitForCurrentActivity(TiUIHelper.java:174)
       E/AndroidRuntime(22724): 	at facebook.FacebookModule.authorize(FacebookModule.java:222)
       E/AndroidRuntime(22724): 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
       E/AndroidRuntime(22724): 	at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:64)
       E/AndroidRuntime(22724): 	at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:884)
       E/AndroidRuntime(22724): 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1107)
       E/AndroidRuntime(22724): 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:329)
       E/AndroidRuntime(22724): 	at android.os.Handler.dispatchMessage(Handler.java:98)
       E/AndroidRuntime(22724): 	at android.os.Looper.loop(Looper.java:137)
       E/AndroidRuntime(22724): 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
       W/ActivityManager(  744):   Force finishing activity com.appcelerator.timob15770/.Timob15770Activity
       
    iii) KS->MASHUPS->Facebook->Login/Logout works fine.
  6. Ping Wang 2013-11-27

    PR: https://github.com/appcelerator/titanium_modules/pull/148 For FR, please run the test case on 4.4 and 4.3 devices. Should not see any error or crash when login/logout.
  7. Pedro Enrique 2013-11-27

    PR approved and merged into _titanium_modules_ master
  8. Ping Wang 2013-11-27

    SDK PR: https://github.com/appcelerator/titanium_mobile/pull/5042 3_2_X backport: https://github.com/appcelerator/titanium_mobile/pull/5043
  9. Pedro Enrique 2013-11-27

    Merged
  10. Lokesh Choudhary 2013-11-27

    Verified the fix. We do not see any app crash when fb.authorize() is used & we successfully get the facebook login propmt. Closing. Environment: Appcel Studio : 3.2.0.201311261642 Ti SDK : 3.2.0.v20131127110843 Mac OSX : 10.8.5 Alloy : 1.3.0 from github CLI - 3.2.0-beta Nexus 5 - android 4.4

JSON Source