This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOS] Avoid crash when backdrop filter is null for PlatformViews #43150
Merged
auto-submit
merged 3 commits into
flutter:main
from
cyanglaz:backdrop_filter_platform_view_crash
Jul 5, 2023
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+20.1 KB
...iew_with_negative_backdrop_filter_iPhone SE (3rd generation)_16.2_simulator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1443,8 +1443,6 @@ class PlatformViewWithOtherBackDropFilter extends PlatformViewScenario { | |
/// A simple platform view for testing backDropFilter with a platform view in the scene. | ||
/// | ||
/// The stack would look like: picture 1 -> pv1 -> picture 2 -> filter -> pv2 - > picture 3. | ||
/// Because backdrop filter on platform views has not been implemented(see: https://github.com/flutter/flutter/issues/43902), | ||
/// the result will not including a filtered pv1. | ||
class TwoPlatformViewsWithOtherBackDropFilter extends Scenario | ||
with _BasePlatformViewScenarioMixin { | ||
/// Constructs the scenario. | ||
|
@@ -1533,6 +1531,68 @@ class TwoPlatformViewsWithOtherBackDropFilter extends Scenario | |
} | ||
} | ||
|
||
/// A simple platform view for testing backDropFilter with a platform view in the scene. | ||
/// | ||
/// The backdrop filter sigma value is negative, which tries to reproduce a crash, see: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curious what does a negative sigma mean? is it not supposed to happen? maybe make sense to print a warning if so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not entirely sure why the negative sigma is used in one of the example code to reproduce the bug, however, the fix is more about accounting the possibility where the filter object is null. As a follow up, I think we also need to disable partial repaint when there is a platform view. |
||
/// https://github.com/flutter/flutter/issues/127095 | ||
class PlatformViewWithNegativeBackDropFilter extends Scenario | ||
with _BasePlatformViewScenarioMixin { | ||
/// Constructs the scenario. | ||
PlatformViewWithNegativeBackDropFilter( | ||
super.view, { | ||
required int id, | ||
}) : _id = id; | ||
|
||
final int _id; | ||
|
||
@override | ||
void onBeginFrame(Duration duration) { | ||
final SceneBuilder builder = SceneBuilder(); | ||
|
||
final PictureRecorder recorder = PictureRecorder(); | ||
final Canvas canvas = Canvas(recorder); | ||
// This is just a background picture to make the result more viewable. | ||
canvas.drawRect( | ||
const Rect.fromLTRB(0, 0, 600, 1000), | ||
Paint()..color = const Color(0xFFFF0000), | ||
); | ||
canvas.drawRect( | ||
const Rect.fromLTRB(0, 0, 300, 300), | ||
Paint()..color = const Color(0xFF00FF00), | ||
); | ||
final Picture picture1 = recorder.endRecording(); | ||
builder.addPicture(Offset.zero, picture1); | ||
|
||
builder.pushOffset(0, 200); | ||
|
||
addPlatformView( | ||
_id, | ||
dispatcher: view.platformDispatcher, | ||
sceneBuilder: builder, | ||
width: 100, | ||
height: 100, | ||
text: 'platform view 1' | ||
); | ||
|
||
final PictureRecorder recorder2 = PictureRecorder(); | ||
final Canvas canvas2 = Canvas(recorder2); | ||
canvas2.drawCircle( | ||
const Offset(200, 100), | ||
50, | ||
Paint()..color = const Color(0xFF0000EF), | ||
); | ||
final Picture picture2 = recorder2.endRecording(); | ||
builder.addPicture(const Offset(100, 100), picture2); | ||
|
||
final ImageFilter filter = ImageFilter.blur(sigmaX: -8, sigmaY: 8); | ||
builder.pushBackdropFilter(filter); | ||
|
||
final Scene scene = builder.build(); | ||
view.render(scene); | ||
scene.dispose(); | ||
} | ||
} | ||
|
||
/// Builds a scenario where many platform views are scrolling and pass under a picture. | ||
class PlatformViewScrollingUnderWidget extends Scenario | ||
with _BasePlatformViewScenarioMixin { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this out dated comment, the backdrop filter on platform views have been implemented.