Skip to content

Commit

Permalink
[CP-stable]Fix another instance of platform view breakage on Android …
Browse files Browse the repository at this point in the history
…14 (#52982)

This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/wiki/Flutter-Cherrypick-Process#automatically-creates-a-cherry-pick-request)
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.
### Issue Link

Fixes flutter/flutter#148662
CP bug flutter/flutter#148885

### Target

stable

### PR Link

TBD

### Changelog Description

Platform view fix for android 14 when multiple activities are used and onMemoryTrim is called. 

### Impacted Users

Users shipping flutter apps on android 14 that use platform viewss 

### Impact Description

Platform views stop rendering new frames. 

### Workaround

No app level work around. 

### Risk

low

### Test Coverage

no

### Validation Steps

App is launched
App is backgrounded (via a back-gesture swipe)
Android Bug triggers HERE
no onTrimMemory callback fires
App is resumed
Platform views don't render
  • Loading branch information
flutteractionsbot authored May 31, 2024
1 parent 55eae68 commit 1801d3b
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ComponentCallbacks2;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
Expand Down Expand Up @@ -645,6 +646,12 @@ void onStop() {
// See https://github.com/flutter/flutter/issues/93276
previousVisibility = flutterView.getVisibility();
flutterView.setVisibility(View.GONE);
if (flutterEngine != null) {
// When an Activity is stopped it won't have its onTrimMemory callback invoked. Normally,
// this isn't a problem but because of a bug in some builds of Android 14 we must act as
// if the onTrimMemory callback has been called.
flutterEngine.getRenderer().onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_BACKGROUND);
}
}

/**
Expand Down

0 comments on commit 1801d3b

Please sign in to comment.