Skip to content

Commit

Permalink
fix(messaging, android): possible fix to a crash occurring on android…
Browse files Browse the repository at this point in the history
… background executor (#12057)
  • Loading branch information
russellwheatley committed Dec 27, 2023
1 parent d37e834 commit 3eaae47
Showing 1 changed file with 11 additions and 0 deletions.
Expand Up @@ -13,6 +13,7 @@
import android.util.Log;
import androidx.annotation.NonNull;
import com.google.firebase.messaging.RemoteMessage;
import io.flutter.FlutterInjector;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.FlutterShellArgs;
import io.flutter.embedding.engine.dart.DartExecutor;
Expand Down Expand Up @@ -138,6 +139,7 @@ public void startBackgroundIsolate() {
* handle does not resolve to a Dart callback then this method does nothing.
* </ul>
*/
@SuppressWarnings("ConstantConditions")
public void startBackgroundIsolate(long callbackHandle, FlutterShellArgs shellArgs) {
if (backgroundFlutterEngine != null) {
Log.e(TAG, "Background isolate already started.");
Expand Down Expand Up @@ -177,6 +179,15 @@ public void startBackgroundIsolate(long callbackHandle, FlutterShellArgs shellAr
FlutterCallbackInformation.lookupCallbackInformation(callbackHandle);
DartExecutor executor = backgroundFlutterEngine.getDartExecutor();
initializeMethodChannel(executor);

if (appBundlePath == null) {
// appBundlePath is possibly "null", this will allow us to fallback to the alternative lookup method.
// See: https://github.com/firebase/flutterfire/issues/9345#issuecomment-1467601511
Log.w(
TAG,
"startBackgroundIsolate: 'appBundlePath' was null, using alternative lookup method.");
appBundlePath = FlutterInjector.instance().flutterLoader().findAppBundlePath();
}
DartCallback dartCallback =
new DartCallback(assets, appBundlePath, flutterCallback);

Expand Down

0 comments on commit 3eaae47

Please sign in to comment.