Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions testing/scenario_app/lib/src/platform_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
required this.secondId,
}) {
_nextFrame = _firstFrame;
channelBuffers.setListener('flutter/lifecycle', _onPlatformMessage);
}

/// The platform view identifier to use for the first platform view.
Expand All @@ -437,13 +438,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
_nextFrame();
}

bool _firstFrameBegan = false;

void _firstFrame() {
if (!_firstFrameBegan) {
channelBuffers.setListener('flutter/lifecycle', _onPlatformMessage);
}
_firstFrameBegan = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change also necessary to fix the issue? will moving this call from firstFrame to the init cause any problem?

Copy link
Contributor Author

@vashworth vashworth Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the change is basically just undoing my first attempt at a fix (#48096), which was still flakey. So no, it shouldn't cause any problems as this was as the code originally was

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha!

final SceneBuilder builder = SceneBuilder();

builder.pushOffset(50, 600);
Expand Down Expand Up @@ -515,6 +510,13 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
PlatformMessageResponseCallback? callback,
) {
final String message = utf8.decode(data!.buffer.asUint8List());

// The expected first event should be 'AppLifecycleState.resumed', but
// occasionally it will receive 'AppLifecycleState.inactive' first. Skip
// any messages until 'AppLifecycleState.resumed' is received.
if (_lastLifecycleState.isEmpty && message != 'AppLifecycleState.resumed') {
return;
}
if (_lastLifecycleState == 'AppLifecycleState.inactive' &&
message == 'AppLifecycleState.resumed') {
_nextFrame = _secondFrame;
Expand Down