question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multi-Process Apps Result in TRANSACTION_URI Not Being Initialized

See original GitHub issue

I tried integrating Chuck into my playground app for CWAC-NetSecurity. Using Chuck either as a regular or network interceptor resulted in:

java.lang.NullPointerException: url
   at com.android.internal.util.Preconditions.checkNotNull(Preconditions.java:60)
   at android.content.ContentResolver.insert(ContentResolver.java:1224)
   at com.readystatesoftware.chuck.ChuckInterceptor.create(ChuckInterceptor.java:172)
   at com.readystatesoftware.chuck.ChuckInterceptor.intercept(ChuckInterceptor.java:114)

This would result from TRANSACTION_URI being null, either because attachInfo() is not being called at all or Uri.parse() returning null.

My playground app uses two processes. My launcher activity brings up a set of preferences to configure the scenario to try. It then starts another activity, running in a separate process, to actually test the scenario.

By default, your ChuckContentProvider goes into the default process. When I try applying Chuck in the other process, ChuckContentProvider.TRANSACTION_URI will be null, because the provider is a natural system-wide singleton, and that singleton is in the other process. Hence, attachInfo() is never called in this process to initialize TRANSACTION_URI.

(this is one of the reasons why I don’t recommend multiple processes for most apps…)

I could use manifest merger to shove ChuckContentProvider into the other process, which in theory should get past this crash. However, then I suspect that your activities will fail, as the default process will not have TRANSACTION_URI. I could further shove all of those into the other process using the same manifest merger approach, and perhaps get all this working. I’m not sure if that’s what you want us to do.

Some possible alternatives:

  • Use a static initializer for TRANSACTION_URI based off of BuildConfig.APPLICATION_ID, and use a static initialization block for the UriMatcher. You’d keep the attachInfo() as is. So, in normal single-process cases, developers could rename the ChuckContentProvider authority and you’re covered. The limitation then is that multi-process apps would be required to leave the default authority alone, so the statically-initialized values are valid.

  • Dump ChuckContentProvider entirely and do something else that does not require static values that might not exist in all processes.

Thoughts?

Thanks!

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:9
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
mnchiucommented, Nov 22, 2017

I, too, have run into this issue.

1reaction
erenbakaccommented, Apr 4, 2018

any solution on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Initializing Firebase in a different process (in multi ...
I have the same problem, and I didn't find any solution, because FirebaseMessagingService aparently runs only on main thread.
Read more >
Custom WorkManager Configuration and Initialization
WorkManager calls your app's custom getWorkManagerConfiguration() method to discover its Configuration . (You do not need to call WorkManager.initialize ...
Read more >
multiprocessing — Process-based parallelism — Python 3.11 ...
The multiprocessing module also introduces APIs which do not have analogs in ... the underlying process pool to be separated from waiting for...
Read more >
Python Multithreading and Multiprocessing Tutorial - Toptal
Python is a popular, powerful, and versatile programming language; however, concurrency and parallelism in Python often seems to be a matter of debate....
Read more >
A Warning Regarding Android App Startup with Multiprocess ...
It turns out that App Startup only runs on the default process. This is on purpose; the assumption is that you may not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found