Bug 6583 - AutoCompleteTextView on a PopupWindow failure
Summary: AutoCompleteTextView on a PopupWindow failure
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.2.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-08-17 11:21 UTC by jeff
Modified: 2012-09-11 06:11 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Bare bones project solution demonstrating AutoCompleteTextView failing to perform filtering when parent layout lives on a PopupWindow (283.94 KB, application/octet-stream)
2012-08-17 11:21 UTC, jeff
Details
equivalent Java test case that also fails. (719.43 KB, application/x-zip-compressed)
2012-09-11 06:02 UTC, Atsushi Eno
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description jeff 2012-08-17 11:21:13 UTC
Created attachment 2368 [details]
Bare bones project solution demonstrating AutoCompleteTextView failing to perform filtering when parent layout lives on a PopupWindow

I've created a Android.Widget.PopupWindow having a layout containing a Android.Widget.AutoCompleteTextView and configured the adapter to for the AutoCompleteTextView following the example in the API "countries" demo.  I've done nothing special otherwise.

Running the application, entering two characters, eg. "b" followed by "a" I expect a dropdown containing the countries starting with "ba" ("Bahrai", "Bangladesh", ...).  The actual result, however, is a message on the device saying that the application has unexpected stopped.

To further try and debug this, I attempted to wrap a try-catch around the faltering AutoCompleteTextView code, but the best I could do was detect that its PerformFiltering() function was the culprit.  No exception was thrown (that I was skilled enough to detect) but overriding the AutoCompleteTextView class and then overriding the PerformFiltering class to NOT call the base.PerformFiltering() function prevented the application crash, though at the expense of losing any potential autocomplete dropdown suggesting the countries that match the entered text.

I've tried this on 2 Android devices: Acer A5000 10.1 inch tablet, and Samsung Galaxy S2 phone.  Both running Android version 4.0.3.  For sake of experimentation, I tried changing the Android target to 4.1 and 3.0 in my IDE and running these configurations on both devices also fails.

I've attached my project solution so the bug should be easily reproducible.
Comment 1 Atsushi Eno 2012-09-07 03:51:50 UTC
Thanks for the simple repro case, which helps a lot.

I couldn't reproduce the unexpected stopper with our (unpublished) master on Lv.15 intel emulator, so it is likely already fixed. Need to make sure with 4.2.5.
Comment 2 Atsushi Eno 2012-09-10 07:44:33 UTC
Not reproducible on 4.2.5 on OSX either. It is still possible that it is VS-only issue...
Comment 3 Atsushi Eno 2012-09-11 03:31:27 UTC
This was confusing. I couldn't reproduce general autocomplete issue on VS2012, but it reproduced on the *new* EditText that appears only after I pushed the button.

So the actual repro steps should be:

- start the activity
- push the button
  - then another EditText appears.
- then type 'b' and then 'a'.

Then it crashes like:

09-11 07:19:33.623 E/AndroidRuntime( 1612): FATAL EXCEPTION: main
09-11 07:19:33.623 E/AndroidRuntime( 1612): android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@b463cd80 is not valid; is your activity running?
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.view.ViewRootImpl.setView(ViewRootImpl.java:513)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:301)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.view.Window$LocalWindowManager.addView(Window.java:537)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.widget.PopupWindow.invokePopup(PopupWindow.java:988)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:897)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.widget.ListPopupWindow.show(ListPopupWindow.java:595)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1062)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.widget.AutoCompleteTextView.updateDropDownForFilter(AutoCompleteTextView.java:939)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.widget.AutoCompleteTextView.onFilterComplete(AutoCompleteTextView.java:921)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:285)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.os.Looper.loop(Looper.java:137)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at android.app.ActivityThread.main(ActivityThread.java:4424)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at java.lang.reflect.Method.invokeNative(Native Method)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at java.lang.reflect.Method.invoke(Method.java:511)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-11 07:19:33.623 E/AndroidRuntime( 1612): 	at dalvik.system.NativeStart.main(Native Method)
09-11 07:19:34.162 I/dalvikvm( 1612): threadid=3: reacting to signal 3
09-11 07:19:34.172 I/dalvikvm( 1612): Wrote stack traces to '/data/anr/traces.txt'

This rather smells like app-level issue. Need to review the equivalent code in Java.
Comment 4 Atsushi Eno 2012-09-11 06:02:44 UTC
Created attachment 2498 [details]
equivalent Java test case that also fails.
Comment 5 Atsushi Eno 2012-09-11 06:11:14 UTC
The attachment at comment #4 is a Java-based Android SDK project. It proves that your application code itself causes the exception reported above.

If you got some working Java code and the equivalent MfA code still failed, please reopen the bug and post the sample repro code.