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

[WorkManagerSample] Toast.show called in a worker, throwing a silent error #1077

Open
JoseAlcerreca opened this issue Jan 11, 2023 · 0 comments
Assignees

Comments

@JoseAlcerreca
Copy link
Contributor

This happens when running the ImageOperationsTest, although the test still passes.

01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: Work [ id=c124293f-e796-4f70-b0db-36e5d7ddaf7e, tags={ OUTPUT, com.example.background.workers.UploadWorker } ] failed because it threw an exception/error
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Can't toast on a thread that has not called Looper.prepare()
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:516)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:311)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.testing.SynchronousExecutor.execute(SynchronousExecutor.java:30)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor.scheduleNext(SerialExecutor.java:55)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:93)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.testing.SynchronousExecutor.execute(SynchronousExecutor.java:30)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor.scheduleNext(SerialExecutor.java:55)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:93)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.testing.SynchronousExecutor.execute(SynchronousExecutor.java:30)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor.scheduleNext(SerialExecutor.java:55)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:93)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.testing.SynchronousExecutor.execute(SynchronousExecutor.java:30)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor.scheduleNext(SerialExecutor.java:55)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:93)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.testing.SynchronousExecutor.execute(SynchronousExecutor.java:30)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor.scheduleNext(SerialExecutor.java:55)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:93)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.testing.SynchronousExecutor.execute(SynchronousExecutor.java:30)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor.scheduleNext(SerialExecutor.java:55)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:93)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.testing.SynchronousExecutor.execute(SynchronousExecutor.java:30)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor.scheduleNext(SerialExecutor.java:55)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:93)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.testing.SynchronousExecutor.execute(SynchronousExecutor.java:30)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor.scheduleNext(SerialExecutor.java:55)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:93)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.testing.SynchronousExecutor.execute(SynchronousExecutor.java:30)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor.scheduleNext(SerialExecutor.java:55)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:93)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.testing.SynchronousExecutor.execute(SynchronousExecutor.java:30)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor.scheduleNext(SerialExecutor.java:55)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor.execute(SerialExecutor.java:46)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.futures.AbstractFuture.executeListener(AbstractFuture.java:1051)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.futures.AbstractFuture.complete(AbstractFuture.java:900)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.futures.AbstractFuture.set(AbstractFuture.java:685)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.futures.SettableFuture.set(SettableFuture.java:51)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at androidx.work.CoroutineWorker$startWork$1.invokeSuspend(CoroutineWorker.kt:69)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
01-11 09:01:01.752 28606 28641 E WM-WorkerWrapper: 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: Caused by: java.lang.NullPointerException: Can't toast on a thread that has not called Looper.prepare()
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at com.android.internal.util.Preconditions.checkNotNull(Preconditions.java:167)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at android.widget.Toast.getLooper(Toast.java:185)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at android.widget.Toast.<init>(Toast.java:170)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at android.widget.Toast.makeText(Toast.java:498)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at android.widget.Toast.makeText(Toast.java:486)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at com.example.background.workers.UploadWorker.toastAndLog(UploadWorker.kt:70)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at com.example.background.workers.UploadWorker.doWork(UploadWorker.kt:64)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at androidx.work.Worker$1.run(Worker.java:86)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at androidx.work.testing.SynchronousExecutor.execute(SynchronousExecutor.java:30)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at androidx.work.Worker.startWork(Worker.java:82)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.WorkerWrapper$1.run(WorkerWrapper.java:295)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at androidx.work.testing.SynchronousExecutor.execute(SynchronousExecutor.java:30)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.futures.AbstractFuture.executeListener(AbstractFuture.java:1051)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.futures.AbstractFuture.addListener(AbstractFuture.java:666)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.WorkerWrapper.runWorker(WorkerWrapper.java:287)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:137)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
01-11 09:01:01.753 28606 28641 E WM-WorkerWrapper: 	... 32 more
01-11 09:01:01.754 28606 28641 I WM-WorkerWrapper: Worker result FAILURE for Work [ id=c124293f-e796-4f70-b0db-36e5d7ddaf7e, tags={ OUTPUT, com.example.background.workers.UploadWorker } ]
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

3 participants
@JoseAlcerreca @tikurahul and others