Closed Bug 1263338 Opened 8 years ago Closed 4 years ago

Investigate removing unnecessary logging from Java code


(Firefox for Android Graveyard :: General, defect)

Not set


(firefox48 affected)

Tracking Status
firefox48 --- affected


(Reporter: rnewman, Unassigned)



(There's probably an old bug on this, but here, have a new one.)

Every RuntimeException string, and every log message (Log.{d,e,v,i}, is compiled into classes.dex. Furthermore, each logging call adds bytecode.

  1756:        Log.d(LOGTAG, "Enabling Android StrictMode");

  $ strings classes.dex| fgrep Enabling
  Enabling Android StrictMode

As Nathan notes in Bug 1263197, this adds to our APK size. Presumably not as much as Gecko's logging does (900KB in libxul!), but it would be worth revisiting.

There are three parts to this bug:

1. Deleting code. Some logging no longer adds value, and we can just delete it.
2. Shortening any excessively verbose exception messages.
3. Conditionalizing some of our non-critical logging code in a way that allows the compiler to delete it from release builds.

ProGuard can do the third:

but note that if any of our logging code has side-effects other than writing a log line, this will break the app. For example:

  int i = 4;
  Log.d(LOG_TAG, "i is " + i++);        // Logs "i is 4"
  return i;                             // Returns 5

isn't safe to prune in this way.

We also rely on our logging in some crash reports, so I would suggest reviewing our log statements to avoid turning off those we might need (hah!), and also making careful use of the early beta flag to maintain full logging for as long as we can.

CCing margaret and snorp to opine, and see if we want to do some little ProGuard tests to see what kind of wins we might see here.
I think this could be a good meta effort, let's start looking at the log messages and see where we can chip away.

To avoid blocking on fixing the world, developers can file sub-bugs with patches whenever they feel motivated to spend 30 mins looking into this.
We have completed our launch of our new Firefox on Android. The development of the new versions use GitHub for issue tracking. If the bug report still reproduces in a current version of [Firefox on Android nightly]( an issue can be reported at the [Fenix GitHub project]( If you want to discuss your report please use [Mozilla's chat]( server and join the [#fenix]( channel.
Closed: 4 years ago
Resolution: --- → INCOMPLETE
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.