bluelinelabs / Conductor

A small, yet full-featured framework that allows building View-based Android applications
Apache License 2.0
3.9k stars 343 forks source link

ConcurrentModificationException iterating Backstack #389

Open toddhodes opened 6 years ago

toddhodes commented 6 years ago

Hi! I'm seeing the following. The flow is from a conductor activity, to a dialog, the calling out to the SMS app, and then when the user hits the back button from the native SMS app, we get the following:

java.util.ConcurrentModificationException                                                            
   at java.util.ArrayDeque$DeqIterator.next(ArrayDeque.java:608)                                     
   at com.bluelinelabs.conductor.Router.onActivityStarted(Router.java:532)                           
   at com.bluelinelabs.conductor.internal.LifecycleHandler.onActivityStarted(LifecycleHandler.java:334)
   at android.app.Application.dispatchActivityStarted(Application.java:205)                          
   at android.app.Activity.onStart(Activity.java:1150)                                               
   at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:564)                     
   at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177)                   
   at com.locationlabs.cni.mvp.BaseControlsActivity.onStart(BaseControlsActivity.java:51)            
   at com.locationlabs.cni.contentfiltering.AppControlsActivity.onStart(AppControlsActivity.java:117)
   at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)                     
   at android.app.Activity.performStart(Activity.java:6268)                                          
   at android.app.Activity.performRestart(Activity.java:6314)                                        
   at android.app.Activity.performResume(Activity.java:6319)                                         
   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3092)                     
   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)                      
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1388)                           
   at android.os.Handler.dispatchMessage(Handler.java:102)                                           
   at android.os.Looper.loop(Looper.java:148)                                                        
   at android.app.ActivityThread.main(ActivityThread.java:5417)                                      
   at java.lang.reflect.Method.invoke(Native Method)                                                 
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)                
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

can you make the Router's Backstack iterator thread-safe, or, provide any other advice? as a workaround, I'm simply catching it and moving on...

   @Override
   protected void onStart() {
      try {
         super.onStart();
         getPresenter().onViewStarted();
      } catch (RuntimeException e) {
         Log.dw("we still need a proper fix for <our-issue-#>");
      }
   }

tried conductor_version=2.1.4 and conductor_version=2.1.5-SNAPSHOT

SamYStudiO commented 6 years ago

+1 got it as well

dimsuz commented 6 years ago

This seems like a duplicate of #396 which has a PR submitted (#406). I'd suggest to close this issue in favor of #396 as it contains more info and comments.

SamYStudiO commented 6 years ago

Hum mine is different

java.util.ConcurrentModificationException
at java.util.ArrayDeque$DescendingIterator.next(ArrayDeque.java:681)
at com.bluelinelabs.conductor.Router.rebindIfNeeded(Router.java:498)
at com.bluelinelabs.conductor.Conductor.attachRouter(Conductor.java:39)

Can be reproduce from this git https://github.com/SamYStudiO/beaver, launch app click invalidate button , then click sign button (2 dialogs controller should be opened over a thirdcontroller) then rotate screen > crash

SamYStudiO commented 6 years ago

Ok I figure out what happend, in fact this is similar to #396, crash happens when you push a new controller while Router.rebindIfNeeded loop is executed, in my case the push is an error on my side, i'm not sure if it has to be fixed or not.

FunnyDevs commented 6 years ago

any news???

dimsuz commented 6 years ago

@SamYStudiO can you check if this is still reproducable for you on recent snapshot? #396 got fixed, chances are your case will be fixed too.

mateherber commented 5 years ago

Same happens for us on 3.0.0-rc2. Any update or possible workaround? It happens while handling push notifications but really hard to repro.

eaglecs commented 3 years ago

Same issue. Please fix it.

daewin commented 2 years ago

Hi @EricKuck, is this issue resolved by https://github.com/bluelinelabs/Conductor/commit/bd584727be913e520baae21cc8013cb5e5d60f11?