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

Random crash: Cannot invoke setBridgeInflater because "context" is null #954

Closed
matejdro opened this issue Jun 20, 2023 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@matejdro
Copy link
Contributor

Description

For us, tests seem to sporadically crash on the CI with the following exception:

java.lang.NullPointerException: Cannot invoke "com.android.layoutlib.bridge.android.BridgeContext.setBridgeInflater(android.view.BridgeInflater)" because "context" is null
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.init(RenderSessionImpl.java:198)
	at app.cash.paparazzi.Paparazzi.prepare(Paparazzi.kt:174)
	at app.cash.paparazzi.Paparazzi$apply$statement$1.evaluate(Paparazzi.kt:123)
	at com.google.testing.junit.testparameterinjector.PluggableTestRunner$ContextMethodRule$1.evaluate(PluggableTestRunner.java:429)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:108)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:40)
	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:60)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)

Sometimes, this happens together with #494 (some tests will fail with this null exception, some with the initSystem error)

Steps to Reproduce

We can't reproduce it reliably. #494 suggests Lottie might be the culprit. Will perform more tests and update this issue if I find anything more concrete.

Expected behavior

Paparazzi shouldn't crash

Additional information:

  • Paparazzi Version: 1.3.0
  • OS: Ubuntu 22.04.2
  • Compile SDK: 33
  • Gradle Version: 8.0.2
  • Android Gradle Plugin Version: 8.0.2
@matejdro matejdro added the bug Something isn't working label Jun 20, 2023
@matejdro
Copy link
Contributor Author

Duplicate of the #630

@jamesrapadmi
Copy link

I'm seeing this issue on all my paparazzi tests, even without SessionParams.RenderingMode.SHRINK and with the following setup block.

@Before
fun setup() {
    LottieTask.EXECUTOR = Executor(Runnable::run)
}

Is there anything else I can do to avoid this?

java.lang.NullPointerException: Cannot invoke "com.android.layoutlib.bridge.android.BridgeContext.setBridgeInflater(android.view.BridgeInflater)" because "context" is null
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.init(RenderSessionImpl.java:198)
	at app.cash.paparazzi.Paparazzi.prepare(Paparazzi.kt:175)
	at app.cash.paparazzi.Paparazzi$apply$statement$1.evaluate(Paparazzi.kt:124)
...

For reference, I'm on:

  • Paparazzi Version: 1.3.1
  • OS: macOS
  • Compile SDK: 34
  • Gradle Version: 8.3
  • Android Gradle Plugin Version: 8.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants