Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

androidx.work.impl.constraints.WorkConstraintsTracker in onConstraintMet - java.util.ConcurrentModificationException #56

Closed
bhsat opened this issue Jul 16, 2018 · 7 comments

Comments

@bhsat
Copy link

bhsat commented Jul 16, 2018

Stack Trace

java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.next(ArrayList.java:831)
at androidx.work.impl.constraints.WorkConstraintsTracker.onConstraintMet(WorkConstraintsTracker.java:120)
at androidx.work.impl.constraints.controllers.ConstraintController.updateCallback(ConstraintController.java:123)
at androidx.work.impl.constraints.controllers.ConstraintController.onConstraintChanged(ConstraintController.java:130)
at androidx.work.impl.constraints.trackers.ConstraintTracker.setState(ConstraintTracker.java:89)
at androidx.work.impl.constraints.trackers.NetworkStateTracker$NetworkStateCallback.onCapabilitiesChanged(NetworkStateTracker.java:136)
at android.net.ConnectivityManager$CallbackHandler.handleMessage(ConnectivityManager.java:2711)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)

hubot pushed a commit to aosp-mirror/platform_frameworks_support that referenced this issue Jul 24, 2018
* There is a chance of a race condition in WorkConstraintsTracker.
  Constraint changes typically take place on the main thread, and
  WorkManager enqueue() and cancel() happens on the WorkManager's task
  executor thread. So there is a chance for a ConcurrentModificationException
  for the list of workSpecs being tracked.

Test: Existing tests pass.

Change-Id: I066ce8e0aa626a2778e77d7eaf69a90fb4e1c9c2
Related GitHub issue: android/codelab-android-workmanager#56
@konstantintuev
Copy link

Is there any workaround while the fix is not in production?

@bakua
Copy link

bakua commented Aug 8, 2018

@konstantintuev AFAIK the fix is already out in alpha-06.

@pfmaggi
Copy link
Collaborator

pfmaggi commented Sep 18, 2018

Thanks for reporting this.
I'm closing this issue because this forum is for issues with the codelab.

If you think that this is a problem of the WorkManager library, please open a bug on the WorkManager public issue tracker: https://issuetracker.google.com/issues/new?component=409906&template=1094197

Please reopen if you still think this is an issue with the codelab.

@pfmaggi pfmaggi closed this as completed Sep 18, 2018
@matpag
Copy link

matpag commented Nov 10, 2018

This has been solved with WorkManager version 1.0.0-alpha11, as described here: https://developer.android.com/jetpack/docs/release-notes#nov_8_2018
(just to inform the people of this thread)

@liujian16
Copy link

@pfmaggi This ConcurrentModificationException is not solved. We use Workmanager 1.0.0-beta2 in our app, but ConcurrentModificationException is still happening in WakeLocks.checkWakeLocks. I have decompiled our app and checked the code of WakeLocks to make sure that we are really using the right version of jar. Yes, we are using the right jar and there are

synchronized (sWakeLocks)

in both newWakeLock and checkWakeLocks methods.

But a lot of crash report
caused by ConcurrentModificationException is recored in play store console. I guess this may be caused by improper implementation of WeakHashMap used in WakeLocks class. While checkWakeLocks method in the loop of iterating sWakeLocks.keySet(), some entry is removed by Garbage Collector.

@liujian16
Copy link

@pfmaggi I just searched issuetracker. Happy to know that a new fix will be in Beta03 and happier to know it did caused by GC just as I guessed.

@pfmaggi
Copy link
Collaborator

pfmaggi commented Feb 22, 2019

Looking on the public IssueTracker, it seems that a similar issue has been fixed in beta-3.

The latest WorkManager version available at this moment is 1.0.0-rc02.

If you think that this problem is still present in the latest version of the WorkManager library, please open a bug on the WorkManager public issue tracker: https://issuetracker.google.com/issues/new?component=409906&template=1094197

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants