Skip to content

Commit c5111cf

Browse files
feat: add instabug_screen_render_manager which control screen render , add instabug_widget_binding_observer which manage app life cycle, refactor ui trace related apis
1 parent afb33df commit c5111cf

28 files changed

+716
-33
lines changed

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip

android/src/main/java/com/instabug/flutter/modules/ApmApi.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ public void isEndScreenLoadingEnabled(@NonNull ApmPigeon.Result<Boolean> result)
345345
isScreenLoadingEnabled(result);
346346
}
347347

348-
349348
@Override
350349
public void isEnabled(@NonNull ApmPigeon.Result<Boolean> result) {
351350
try {
@@ -385,4 +384,20 @@ public void setScreenLoadingEnabled(@NonNull Boolean isEnabled) {
385384
e.printStackTrace();
386385
}
387386
}
387+
388+
389+
@Override
390+
public void isScreenRenderEnabled(@NonNull ApmPigeon.Result<Boolean> result) {
391+
try {
392+
result.success(true);
393+
} catch (Exception e) {
394+
e.printStackTrace();
395+
}
396+
}
397+
398+
@Override
399+
public void deviceRefreshRate(@NonNull ApmPigeon.Result<Double> result) {
400+
result.success(60.0);
401+
}
402+
388403
}

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ SPEC CHECKSUMS:
3030

3131
PODFILE CHECKSUM: 8f7552fd115ace1988c3db54a69e4a123c448f84
3232

33-
COCOAPODS: 1.16.2
33+
COCOAPODS: 1.15.2

example/ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import UIKit
22
import Flutter
33

4-
@UIApplicationMain
4+
@main
55
@objc class AppDelegate: FlutterAppDelegate {
66
override func application(
77
_ application: UIApplication,

example/lib/main.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ part 'src/screens/screen_loading_page.dart';
3030

3131
part 'src/screens/my_home_page.dart';
3232

33+
part 'src/screens/screen_render_page.dart';
34+
3335
part 'src/components/fatal_crashes_content.dart';
3436

3537
part 'src/components/non_fatal_crashes_content.dart';
@@ -42,6 +44,10 @@ part 'src/components/traces_content.dart';
4244

4345
part 'src/components/flows_content.dart';
4446

47+
part 'src/components/screen_render.dart';
48+
49+
part 'src/components/animated_box.dart';
50+
4551
void main() {
4652
runZonedGuarded(
4753
() {
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
part of '../../main.dart';
2+
3+
class AnimatedBox extends StatefulWidget {
4+
const AnimatedBox({Key? key}) : super(key: key);
5+
6+
@override
7+
_AnimatedBoxState createState() => _AnimatedBoxState();
8+
}
9+
10+
class _AnimatedBoxState extends State<AnimatedBox>
11+
with SingleTickerProviderStateMixin {
12+
late AnimationController _controller;
13+
late Animation<double> _animation;
14+
15+
@override
16+
void initState() {
17+
super.initState();
18+
_controller = AnimationController(
19+
duration: const Duration(minutes: 1 , seconds: 40),
20+
vsync: this,
21+
);
22+
_animation = Tween<double>(begin: 0, end: 100).animate(_controller)
23+
..addListener(() {
24+
setState(() {
25+
// The state that has changed here is the animation value
26+
});
27+
});
28+
}
29+
30+
@override
31+
void dispose() {
32+
_controller.dispose();
33+
super.dispose();
34+
}
35+
36+
void _startAnimation() {
37+
_controller.forward();
38+
}
39+
40+
void _stopAnimation() {
41+
_controller.stop();
42+
}
43+
44+
void _resetAnimation() {
45+
_controller.reset();
46+
}
47+
48+
@override
49+
Widget build(BuildContext context) {
50+
return Column(
51+
mainAxisAlignment: MainAxisAlignment.center,
52+
children: <Widget>[
53+
RotationTransition(
54+
turns: _animation,
55+
child: const FlutterLogo(size: 100),
56+
),
57+
const SizedBox(height: 20),
58+
Row(
59+
mainAxisAlignment: MainAxisAlignment.center,
60+
children: <Widget>[
61+
ElevatedButton(
62+
onPressed: () => _startAnimation(),
63+
child: const Text('Start'),
64+
),
65+
const SizedBox(width: 20),
66+
ElevatedButton(
67+
onPressed: () => _stopAnimation(),
68+
child: const Text('Stop'),
69+
),
70+
const SizedBox(width: 20),
71+
ElevatedButton(
72+
onPressed: () => _resetAnimation(),
73+
child: const Text('reset'),
74+
),
75+
],
76+
),
77+
],
78+
);
79+
}
80+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
part of '../../main.dart';
2+
3+
class ScreenRender extends StatelessWidget {
4+
const ScreenRender({Key? key}) : super(key: key);
5+
6+
@override
7+
Widget build(BuildContext context) {
8+
return Column(
9+
children: [
10+
const SectionTitle('Screen Render'),
11+
InstabugButton(
12+
text: 'Screen Render',
13+
onPressed: () => _navigateToScreenRender(context),
14+
),
15+
],
16+
);
17+
}
18+
19+
_navigateToScreenRender(BuildContext context) {
20+
Navigator.push(
21+
context,
22+
MaterialPageRoute(
23+
builder: (context) => const InstabugCaptureScreenLoading(
24+
screenName: ScreenRenderPage.screenName,
25+
child: ScreenRenderPage(),
26+
),
27+
settings: const RouteSettings(name: ScreenRenderPage.screenName),
28+
),
29+
);
30+
}
31+
}

example/lib/src/screens/apm_page.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class _ApmPageState extends State<ApmPage> {
5151
SizedBox.fromSize(
5252
size: const Size.fromHeight(12),
5353
),
54+
ScreenRender(),
5455
],
5556
);
5657
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
part of '../../main.dart';
2+
3+
class ScreenRenderPage extends StatelessWidget {
4+
const ScreenRenderPage({Key? key}) : super(key: key);
5+
static const String screenName = "/screenRenderPageRoute";
6+
7+
@override
8+
Widget build(BuildContext context) {
9+
return Page(title: 'Screen Render', children: [
10+
11+
const AnimatedBox(),
12+
SizedBox.fromSize(size: const Size.fromHeight(50),),
13+
InstabugButton(
14+
text: 'Perform Frozen Frame',
15+
onPressed: () => _simulateHeavyComputation(),
16+
),
17+
InstabugButton(
18+
text: 'Monitored Complex Page',
19+
onPressed: () => _navigateToComplexPage(context),
20+
),
21+
]);
22+
}
23+
24+
void _navigateToComplexPage(BuildContext context) {
25+
Navigator.push(
26+
context,
27+
MaterialPageRoute(
28+
builder: (context) => const ComplexPage.monitored(),
29+
settings: const RouteSettings(
30+
name: ComplexPage.screenName,
31+
),
32+
),
33+
);
34+
}
35+
36+
// Simulates a computationally expensive task
37+
void _simulateHeavyComputation() {
38+
final startTime = DateTime.now();
39+
// Block the UI thread for ~500ms
40+
while (DateTime.now().difference(startTime).inMilliseconds <= 1000) {
41+
// Busy waiting (not recommended in real apps)
42+
}
43+
}
44+
}

example/pubspec.lock

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ packages:
3737
dependency: transitive
3838
description:
3939
name: collection
40-
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
40+
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
4141
url: "https://pub.dev"
4242
source: hosted
43-
version: "1.18.0"
43+
version: "1.19.0"
4444
fake_async:
4545
dependency: transitive
4646
description:
@@ -120,18 +120,18 @@ packages:
120120
dependency: transitive
121121
description:
122122
name: leak_tracker
123-
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
123+
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
124124
url: "https://pub.dev"
125125
source: hosted
126-
version: "10.0.5"
126+
version: "10.0.7"
127127
leak_tracker_flutter_testing:
128128
dependency: transitive
129129
description:
130130
name: leak_tracker_flutter_testing
131-
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
131+
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
132132
url: "https://pub.dev"
133133
source: hosted
134-
version: "3.0.5"
134+
version: "3.0.8"
135135
leak_tracker_testing:
136136
dependency: transitive
137137
description:
@@ -200,7 +200,7 @@ packages:
200200
dependency: transitive
201201
description: flutter
202202
source: sdk
203-
version: "0.0.99"
203+
version: "0.0.0"
204204
source_span:
205205
dependency: transitive
206206
description:
@@ -213,10 +213,10 @@ packages:
213213
dependency: transitive
214214
description:
215215
name: stack_trace
216-
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
216+
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
217217
url: "https://pub.dev"
218218
source: hosted
219-
version: "1.11.1"
219+
version: "1.12.0"
220220
stream_channel:
221221
dependency: transitive
222222
description:
@@ -229,10 +229,10 @@ packages:
229229
dependency: transitive
230230
description:
231231
name: string_scanner
232-
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
232+
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
233233
url: "https://pub.dev"
234234
source: hosted
235-
version: "1.2.0"
235+
version: "1.3.0"
236236
sync_http:
237237
dependency: transitive
238238
description:
@@ -253,10 +253,10 @@ packages:
253253
dependency: transitive
254254
description:
255255
name: test_api
256-
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
256+
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
257257
url: "https://pub.dev"
258258
source: hosted
259-
version: "0.7.2"
259+
version: "0.7.3"
260260
typed_data:
261261
dependency: transitive
262262
description:
@@ -277,18 +277,18 @@ packages:
277277
dependency: transitive
278278
description:
279279
name: vm_service
280-
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
280+
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
281281
url: "https://pub.dev"
282282
source: hosted
283-
version: "14.2.5"
283+
version: "14.3.0"
284284
webdriver:
285285
dependency: transitive
286286
description:
287287
name: webdriver
288-
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
288+
sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8"
289289
url: "https://pub.dev"
290290
source: hosted
291-
version: "3.0.3"
291+
version: "3.0.4"
292292
sdks:
293293
dart: ">=3.5.0 <4.0.0"
294294
flutter: ">=3.18.0-18.0.pre.54"

0 commit comments

Comments
 (0)