-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use
addTimingsCallback
instead of addPostFrameCallback
to d…
…etermine app start end (#2405) * use addTimingsCallback * update test * update * update naming * update naming * update changelog * fix test * check if using custom timingscallback works
- Loading branch information
Showing
11 changed files
with
199 additions
and
137 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -1,33 +1,33 @@ | ||
import 'package:flutter/scheduler.dart'; | ||
import 'package:sentry_flutter/src/frame_callback_handler.dart'; | ||
|
||
import 'mocks.dart'; | ||
|
||
class FakeFrameCallbackHandler implements FrameCallbackHandler { | ||
final Duration finishAfterDuration; | ||
FakeFrameCallbackHandler({this.postFrameCallbackDelay}); | ||
|
||
FakeFrameCallbackHandler( | ||
{this.finishAfterDuration = const Duration(milliseconds: 50)}); | ||
/// If set, it automatically executes the callback after the delay | ||
Duration? postFrameCallbackDelay; | ||
FrameCallback? postFrameCallback; | ||
TimingsCallback? timingsCallback; | ||
|
||
@override | ||
void addPostFrameCallback(FrameCallback callback) async { | ||
// ignore: inference_failure_on_instance_creation | ||
await Future.delayed(finishAfterDuration); | ||
callback(Duration.zero); | ||
} | ||
postFrameCallback = callback; | ||
|
||
@override | ||
Future<void> addPersistentFrameCallback(FrameCallback callback) async { | ||
for (final duration in fakeFrameDurations) { | ||
// Let's wait a bit so the timestamp intervals are large enough | ||
await Future<void>.delayed(Duration(milliseconds: 20)); | ||
callback(duration); | ||
if (postFrameCallbackDelay != null) { | ||
await Future<void>.delayed(postFrameCallbackDelay!); | ||
callback(Duration.zero); | ||
} | ||
} | ||
|
||
@override | ||
bool hasScheduledFrame = true; | ||
void addTimingsCallback(TimingsCallback callback) { | ||
timingsCallback = callback; | ||
} | ||
|
||
@override | ||
Future<void> get endOfFrame => Future<void>.value(); | ||
void removeTimingsCallback(TimingsCallback callback) { | ||
if (timingsCallback == callback) { | ||
timingsCallback = null; | ||
} | ||
} | ||
} |
Oops, something went wrong.