Skip to content

Commit

Permalink
Add @DoNotStrip to method called from cpp in bridgeless mode
Browse files Browse the repository at this point in the history
Summary:
I hit a crash when testing bridgeless mode in a release build:

Error: Exception in HostFunction: java.lang.NoSuchMethodError: no non-static method "Lcom/facebook/react/modules/core/JavaTimerManager;.createTimer(IJZ)V"

It turns out that `JavaTimerManager.createTimer()` is getting stripped from release builds because it's not referenced in Java at all. Adding `DoNotStrip` annotation to keep it around. The other methods in JavaTimerManager don't need this because they're referenced by TimingModule - this is the only method that's only used directly from C++ by bridgeless mode.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D19655519

fbshipit-source-id: 8b9862475986bb84b12d81f73f677cc2e4860c67
  • Loading branch information
Emily Janzer authored and facebook-github-bot committed Jan 31, 2020
1 parent 2f758c3 commit d3b2ac3
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import android.util.SparseArray;
import androidx.annotation.Nullable;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.UiThreadUtil;
Expand Down Expand Up @@ -293,6 +294,7 @@ private void clearChoreographerIdleCallback() {
* @param delay The time in ms before the callback should be invoked.
* @param repeat Whether the timer should be repeated (used for setInterval).
*/
@DoNotStrip
public void createTimer(final int callbackID, final long delay, final boolean repeat) {
long initialTargetTime = SystemClock.nanoTime() / 1000000 + delay;
Timer timer = new Timer(callbackID, initialTargetTime, (int) delay, repeat);
Expand Down

0 comments on commit d3b2ac3

Please sign in to comment.