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
Do not instantiate the Runtime in crash reporter service #259
Conversation
Let's retake this later |
a65f1f6
to
27b73a3
Compare
Should resolve #1029 Now it looks like it's fixed, as I can see in the log that
|
Managed to replace deprecated JobIntentService with Service by referring to |
cc: @svillar in case you haven't aware that this is reopened. |
6cf5304
to
d55d360
Compare
app/src/common/chromium/com/igalia/wolvic/browser/api/impl/CrashReporterServiceImpl.java
Outdated
Show resolved
Hide resolved
d55d360
to
ee91ad4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-approve
Currently the CrashReporter service uses the runtime to create a CrashReportIntent. The reason why it does that is because the CrashReportIntent receives some parameters that depend on the backend (Gecko,Chromium) which cannot be resolved at build time. By the time the CrashReporter creates that intent the runtime might not exist (like after a crash in the application). This means that the service will try to create it. The problem is that creating the runtime might not be possible, for example the GeckoRuntime must be created in the main thread but the crash reporter service is run in an async task as it can be see in this backtrace: 2022-09-08 14:15:38.005 20233-20267/com.igalia.wolvic.dev E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: com.igalia.wolvic.dev:crash, PID: 20233 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$4.done(AsyncTask.java:399) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919) Caused by: java.lang.IllegalThreadStateException: Expected thread 2 ("main"), but running on thread 930 ("AsyncTask #1") at org.mozilla.gecko.util.ThreadUtils.assertOnThreadComparison(ThreadUtils.java:127) at org.mozilla.gecko.util.ThreadUtils.assertOnThread(ThreadUtils.java:93) at org.mozilla.gecko.util.ThreadUtils.assertOnUiThread(ThreadUtils.java:84) at org.mozilla.geckoview.GeckoRuntime.create(GeckoRuntime.java:552) at com.igalia.wolvic.browser.api.impl.RuntimeImpl.<init>(RuntimeImpl.java:72) at com.igalia.wolvic.browser.api.WFactory.createRuntime(WFactory.java:14) at com.igalia.wolvic.browser.engine.EngineProvider.getOrCreateRuntime(EngineProvider.kt:67) at com.igalia.wolvic.crashreporting.CrashReporterService.onHandleWork(CrashReporterService.java:65) at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:392) at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:383) at android.os.AsyncTask$3.call(AsyncTask.java:378) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919) This is why we have to add an extra class per backend that is able to create those intents without having to instantiate the runtime. Signed-off-by: Songlin Jiang <sjiang@igalia.com>
By referring to https://github.com/fabricedesre/gecko-dev/blob/master/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/ExampleCrashHandler.java Signed-off-by: Songlin Jiang <sjiang@igalia.com>
ee91ad4
to
b18f429
Compare
Abandoning. We've already landed a couple of patches mitigating this issue. |
Currently the CrashReporter service uses the runtime to create a CrashReportIntent. The reason why it does that is because the CrashReportIntent receives some parameters that depend on the backend (Gecko,Chromium) which cannot be resolved at build time.
By the time the CrashReporter creates that intent the runtime might not exist (like after a crash in the application). This means that the service will try to create it. The problem is that creating the runtime might not be possible, for example the GeckoRuntime must be created in the main thread but the crash reporter service is run in an async task as it can be see in this backtrace:
2022-09-08 14:15:38.005 20233-20267/com.igalia.wolvic.dev E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.igalia.wolvic.dev:crash, PID: 20233
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:399)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.IllegalThreadStateException: Expected thread 2 ("main"), but running on thread 930 ("AsyncTask #1")
at org.mozilla.gecko.util.ThreadUtils.assertOnThreadComparison(ThreadUtils.java:127)
at org.mozilla.gecko.util.ThreadUtils.assertOnThread(ThreadUtils.java:93)
at org.mozilla.gecko.util.ThreadUtils.assertOnUiThread(ThreadUtils.java:84)
at org.mozilla.geckoview.GeckoRuntime.create(GeckoRuntime.java:552)
at com.igalia.wolvic.browser.api.impl.RuntimeImpl.(RuntimeImpl.java:72)
at com.igalia.wolvic.browser.api.WFactory.createRuntime(WFactory.java:14)
at com.igalia.wolvic.browser.engine.EngineProvider.getOrCreateRuntime(EngineProvider.kt:67)
at com.igalia.wolvic.crashreporting.CrashReporterService.onHandleWork(CrashReporterService.java:65)
at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:392)
at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:383)
at android.os.AsyncTask$3.call(AsyncTask.java:378)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
This is why we have to add an extra class per backend that is able to create those intents without having to instantiate the runtime.