Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-18132

Android: App Crashes with CalledFromWrongThreadException opening DatePicker after typing in a tf

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 3.3.0, Release 3.4.0, Release 3.4.1
    • Fix Version/s: Release 5.2.0
    • Component/s: Android
    • Environment:

      Samsung Galaxy 3
      Android OS: 4.3
      Mobile SDK 3.4.0.GA, 3.4.1.GA

    • Story Points:
      8
    • Sprint:
      2015 Sprint 25 SDK

      Description

      Problem Description

      App crashes with CalledFromWrongThreadException when switching from textedit to datepicker

      Steps to reproduce

      1. Create a new mobile project classic titanium
      2. Add this code to app.js:

      var win = Ti.UI.createWindow({title:'test',layout:'vertical'});
      win.open();
      var label = Ti.UI.createTextField({value:'Hello world',top:50,bottom:50,height:Ti.UI.SIZE,width:Ti.UI.FILL});
      win.add(label);
      var picker = Ti.UI.createPicker({value : new Date(),type: Ti.UI.PICKER_TYPE_DATE});
      var pickDateButton = Ti.UI.createButton({title:'pick a date'});
      win.add(pickDateButton);
      pickDateButton.addEventListener('click',function(){
          picker.showDatePickerDialog({
              value:new Date(),
              callback:function(e){
                  Ti.API.info('picked date: '+JSON.stringify(e));
              }
          });
      });
      

      3. Run the app in a Samsung S3 device (Please: make sure to use the S3 device, it's not easily reproducible in other devices).
      4. Click in the Textfield
      5. Start type something
      6. Click on the button to open the date picker .
      7. The app should crash.

      Extra info

      I included the adb log of the errror


      /dalvikvm(27883): threadid=10: thread exiting with uncaught exception (group=0x4174ee48)
      E/AndroidRuntime(27883): FATAL EXCEPTION: KrollRuntimeThread
      E/AndroidRuntime(27883): Process: com.debugging.test, PID: 27883
      E/AndroidRuntime(27883): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
      E/AndroidRuntime(27883): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6347)
      E/AndroidRuntime(27883): at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:871)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.widget.ScrollView.requestLayout(ScrollView.java:1481)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.view.View.requestLayout(View.java:16472)
      E/AndroidRuntime(27883): at android.widget.TextView.checkForResize(TextView.java:6760)
      E/AndroidRuntime(27883): at android.widget.TextView.updateAfterEdit(TextView.java:7681)
      E/AndroidRuntime(27883): at android.widget.Editor.finishBatchEdit(Editor.java:1322)
      E/AndroidRuntime(27883): at android.widget.Editor.endBatchEdit(Editor.java:1305)
      E/AndroidRuntime(27883): at android.widget.TextView.endBatchEdit(TextView.java:6065)
      E/AndroidRuntime(27883): at com.android.internal.widget.EditableInputConnection.endBatchEdit(EditableInputConnection.java:77)
      E/AndroidRuntime(27883): at android.view.inputmethod.BaseInputConnection.finishComposingText(BaseInputConnection.java:288)
      E/AndroidRuntime(27883): at android.view.inputmethod.InputMethodManager.checkFocusNoStartInput(InputMethodManager.java:1358)
      E/AndroidRuntime(27883): at android.view.inputmethod.InputMethodManager.onWindowFocus(InputMethodManager.java:1402)
      E/AndroidRuntime(27883): at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3198)
      E/AndroidRuntime(27883): at android.os.Handler.dispatchMessage(Handler.java:102)
      E/AndroidRuntime(27883): at android.os.Looper.loop(Looper.java:136)
      E/AndroidRuntime(27883): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
      W/ActivityManager( 886): Force finishing activity com.debugging.test/org.appcelerator.titanium.TiActivity
      V/ActivityManager( 886): Moving to PAUSING: ActivityRecord{422ff478 u0 com.debugging.test/org.appcelerator.titanium.TiActivity t1034 f}

        Attachments

          Activity

            People

            • Assignee:
              hpham Hieu Pham
              Reporter:
              bar b Bar Bruy
              Reviewer:
              Ashraf Abu (Inactive)
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-19424
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code