Skip to content

Commit 852884e

Browse files
Merge pull request #582 from Instabug/feat/screen-render
2 parents 5d82000 + 2ae2acc commit 852884e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2842
-194
lines changed

android/build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ rootProject.allprojects {
1616
repositories {
1717
google()
1818
mavenCentral()
19+
maven {
20+
url "https://mvn.instabug.com/nexus/repository/instabug-internal/"
21+
credentials {
22+
username "instabug"
23+
password System.getenv("INSTABUG_REPOSITORY_PASSWORD")
24+
}
25+
}
1926
}
2027
}
2128

29+
2230
apply plugin: 'com.android.library'
2331

2432
android {
@@ -44,11 +52,10 @@ android {
4452
}
4553

4654
dependencies {
47-
api 'com.instabug.library:instabug:14.3.0'
55+
api 'com.instabug.library:instabug:15.0.0.6897042-SNAPSHOT'
4856
testImplementation 'junit:junit:4.13.2'
4957
testImplementation "org.mockito:mockito-inline:3.12.1"
5058
testImplementation "io.mockk:mockk:1.13.13"
51-
5259
}
5360

5461
// add upload_symbols task

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/InstabugFlutterPlugin.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import android.app.Activity;
55
import android.content.Context;
66
import android.graphics.Bitmap;
7+
import android.os.Build;
78
import android.util.Log;
9+
import android.view.Display;
810
import android.view.View;
911

1012
import androidx.annotation.NonNull;
@@ -73,7 +75,14 @@ public Bitmap call() {
7375
}
7476
};
7577

76-
ApmApi.init(messenger);
78+
Callable<Float> refreshRateProvider = new Callable<Float>() {
79+
@Override
80+
public Float call(){
81+
return getRefreshRate();
82+
}
83+
};
84+
85+
ApmApi.init(messenger, refreshRateProvider);
7786
BugReportingApi.init(messenger);
7887
CrashReportingApi.init(messenger);
7988
FeatureRequestsApi.init(messenger);
@@ -99,4 +108,20 @@ private static Bitmap takeScreenshot(FlutterRenderer renderer) {
99108
return null;
100109
}
101110
}
111+
112+
private static float getRefreshRate() {
113+
float refreshRate = 60f;
114+
115+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
116+
final Display display = activity.getDisplay();
117+
if (display != null) {
118+
refreshRate = display.getRefreshRate();
119+
}
120+
} else {
121+
refreshRate = activity.getWindowManager().getDefaultDisplay().getRefreshRate();
122+
}
123+
124+
return refreshRate;
125+
}
126+
102127
}

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

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,20 @@
2323
import java.lang.reflect.Method;
2424
import java.util.HashMap;
2525
import java.util.Map;
26+
import java.util.concurrent.Callable;
2627

2728
public class ApmApi implements ApmPigeon.ApmHostApi {
2829
private final String TAG = ApmApi.class.getName();
2930
private final HashMap<String, ExecutionTrace> traces = new HashMap<>();
31+
private final Callable<Float> refreshRate;
3032

31-
public static void init(BinaryMessenger messenger) {
32-
final ApmApi api = new ApmApi();
33+
public ApmApi(Callable<Float> refreshRate) {
34+
this.refreshRate = refreshRate;
35+
}
36+
37+
public static void init(BinaryMessenger messenger, Callable<Float> refreshRateProvider) {
38+
39+
final ApmApi api = new ApmApi(refreshRateProvider);
3340
ApmPigeon.ApmHostApi.setup(messenger, api);
3441
}
3542

@@ -435,7 +442,6 @@ public void isEndScreenLoadingEnabled(@NonNull ApmPigeon.Result<Boolean> result)
435442
isScreenLoadingEnabled(result);
436443
}
437444

438-
439445
@Override
440446
public void isEnabled(@NonNull ApmPigeon.Result<Boolean> result) {
441447
try {
@@ -475,4 +481,37 @@ public void setScreenLoadingEnabled(@NonNull Boolean isEnabled) {
475481
e.printStackTrace();
476482
}
477483
}
484+
485+
@Override
486+
public void setScreenRenderEnabled(@NonNull Boolean isEnabled) {
487+
try {
488+
APM.setScreenRenderingEnabled(isEnabled);
489+
} catch (Exception e) {
490+
e.printStackTrace();
491+
}
492+
}
493+
494+
@Override
495+
public void isScreenRenderEnabled(@NonNull ApmPigeon.Result<Boolean> result) {
496+
try {
497+
InternalAPM._isFeatureEnabledCP(APMFeature.SCREEN_RENDERING, "InstabugCaptureScreenRender", new FeatureAvailabilityCallback() {
498+
@Override
499+
public void invoke(boolean isEnabled) {
500+
result.success(isEnabled);
501+
}
502+
});
503+
} catch (Exception e) {
504+
e.printStackTrace();
505+
}
506+
}
507+
508+
@Override
509+
public void deviceRefreshRate(@NonNull ApmPigeon.Result<Double> result) {
510+
try {
511+
result.success(refreshRate.call().doubleValue());
512+
} catch (Exception e) {
513+
e.printStackTrace();
514+
}
515+
}
516+
478517
}

android/src/test/java/com/instabug/flutter/ApmApiTest.java

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
import static org.mockito.ArgumentMatchers.anyString;
99
import static org.mockito.ArgumentMatchers.eq;
1010
import static org.mockito.Mockito.mock;
11-
import static org.mockito.Mockito.mockConstruction;
1211
import static org.mockito.Mockito.mockStatic;
12+
import static org.mockito.Mockito.spy;
1313
import static org.mockito.Mockito.verify;
14-
import static org.mockito.Mockito.when;
1514

1615
import com.instabug.apm.APM;
1716
import com.instabug.apm.InternalAPM;
@@ -24,8 +23,6 @@
2423
import com.instabug.flutter.util.GlobalMocks;
2524
import com.instabug.flutter.util.MockReflected;
2625

27-
import io.flutter.plugin.common.BinaryMessenger;
28-
2926
import org.json.JSONObject;
3027
import org.junit.After;
3128
import org.junit.Assert;
@@ -36,18 +33,21 @@
3633

3734
import java.util.HashMap;
3835
import java.util.Map;
36+
import java.util.concurrent.Callable;
3937

4038
import static com.instabug.flutter.util.GlobalMocks.reflected;
4139
import static com.instabug.flutter.util.MockResult.makeResult;
4240
import static org.junit.Assert.assertEquals;
4341
import static org.mockito.ArgumentMatchers.*;
4442
import static org.mockito.Mockito.*;
43+
import io.flutter.plugin.common.BinaryMessenger;
4544

4645

4746
public class ApmApiTest {
4847

4948
private final BinaryMessenger mMessenger = mock(BinaryMessenger.class);
50-
private final ApmApi api = new ApmApi();
49+
private final Callable<Float> refreshRateProvider = () -> mock(Float.class);
50+
private final ApmApi api = new ApmApi(refreshRateProvider);
5151
private MockedStatic<APM> mAPM;
5252
private MockedStatic<InternalAPM> mInternalApmStatic;
5353
private MockedStatic<ApmPigeon.ApmHostApi> mHostApi;
@@ -83,7 +83,7 @@ private ExecutionTrace mockTrace(String id) {
8383
public void testInit() {
8484
BinaryMessenger messenger = mock(BinaryMessenger.class);
8585

86-
ApmApi.init(messenger);
86+
ApmApi.init(messenger, refreshRateProvider);
8787

8888
mHostApi.verify(() -> ApmPigeon.ApmHostApi.setup(eq(messenger), any(ApmApi.class)));
8989
}
@@ -386,4 +386,34 @@ public void testSetScreenLoadingMonitoringEnabled() {
386386

387387
mAPM.verify(() -> APM.setScreenLoadingEnabled(isEnabled));
388388
}
389+
390+
@Test
391+
public void testIsScreenRenderEnabled() {
392+
393+
boolean expected = true;
394+
ApmPigeon.Result<Boolean> result = spy(makeResult((actual) -> assertEquals(expected, actual)));
395+
396+
mInternalApmStatic.when(() -> InternalAPM._isFeatureEnabledCP(any(), any(), any())).thenAnswer(
397+
invocation -> {
398+
FeatureAvailabilityCallback callback = (FeatureAvailabilityCallback) invocation.getArguments()[2];
399+
callback.invoke(expected);
400+
return null;
401+
});
402+
403+
404+
api.isScreenRenderEnabled(result);
405+
406+
mInternalApmStatic.verify(() -> InternalAPM._isFeatureEnabledCP(any(), any(), any()));
407+
mInternalApmStatic.verifyNoMoreInteractions();
408+
409+
verify(result).success(expected);
410+
}
411+
412+
public void testSetScreenRenderEnabled() {
413+
boolean isEnabled = false;
414+
415+
api.setScreenRenderEnabled(isEnabled);
416+
417+
mAPM.verify(() -> APM.setScreenRenderingEnabled(isEnabled));
418+
}
389419
}

example/ios/Podfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ target 'Runner' do
3030

3131
use_frameworks!
3232
use_modular_headers!
33-
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/fix-main-thread-warning/15.0.0/Instabug.podspec'
33+
# pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/fix-main-thread-warning/15.0.0/Instabug.podspec'
34+
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/faeture-screen_rendering-release/15.1.0/Instabug.podspec'
3435

3536
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
3637
end

example/ios/Podfile.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
PODS:
22
- Flutter (1.0.0)
3-
- Instabug (15.0.0)
3+
- Instabug (15.1.0)
44
- instabug_flutter (14.3.0):
55
- Flutter
6-
- Instabug (= 15.0.0)
6+
- Instabug (= 15.1.0)
77
- OCMock (3.6)
88

99
DEPENDENCIES:
1010
- Flutter (from `Flutter`)
11-
- Instabug (from `https://ios-releases.instabug.com/custom/fix-main-thread-warning/15.0.0/Instabug.podspec`)
11+
- Instabug (from `https://ios-releases.instabug.com/custom/faeture-screen_rendering-release/15.1.0/Instabug.podspec`)
1212
- instabug_flutter (from `.symlinks/plugins/instabug_flutter/ios`)
1313
- OCMock (= 3.6)
1414

@@ -20,16 +20,16 @@ EXTERNAL SOURCES:
2020
Flutter:
2121
:path: Flutter
2222
Instabug:
23-
:podspec: https://ios-releases.instabug.com/custom/fix-main-thread-warning/15.0.0/Instabug.podspec
23+
:podspec: https://ios-releases.instabug.com/custom/faeture-screen_rendering-release/15.1.0/Instabug.podspec
2424
instabug_flutter:
2525
:path: ".symlinks/plugins/instabug_flutter/ios"
2626

2727
SPEC CHECKSUMS:
2828
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
29-
Instabug: 3b1db5a683e85ec5a02946aa2b3314036f9022be
30-
instabug_flutter: e59da7a0cae82ce00b2773625ee544c275442000
29+
Instabug: a2b8c384cd4af7a01ab43b2ce2957a880f8862d7
30+
instabug_flutter: 6ee721f30066123a769da64b687eded6eb4ff125
3131
OCMock: 5ea90566be239f179ba766fd9fbae5885040b992
3232

33-
PODFILE CHECKSUM: c16418947581b888c337ed7ff120a59b4b5f3f3f
33+
PODFILE CHECKSUM: e6e180d6b55e3a12f55f266c3f4d8654480877ef
3434

35-
COCOAPODS: 1.16.2
35+
COCOAPODS: 1.15.2

example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<MacroExpansion>
3132
<BuildableReference
@@ -63,11 +64,13 @@
6364
buildConfiguration = "Debug"
6465
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
6566
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
67+
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
6668
launchStyle = "0"
6769
useCustomWorkingDirectory = "NO"
6870
ignoresPersistentStateOnLaunch = "NO"
6971
debugDocumentVersioning = "YES"
7072
debugServiceExtension = "internal"
73+
enableGPUValidationMode = "1"
7174
allowLocationSimulation = "YES">
7275
<BuildableProductRunnable
7376
runnableDebuggingMode = "0">

example/lib/main.dart

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,40 @@
11
import 'dart:async';
2+
import 'dart:convert';
23
import 'dart:developer';
34
import 'dart:io';
4-
import 'dart:convert';
55

66
import 'package:flutter/material.dart';
77
import 'package:instabug_flutter/instabug_flutter.dart';
8-
import 'package:instabug_flutter_example/src/components/apm_switch.dart';
9-
import 'package:instabug_http_client/instabug_http_client.dart';
8+
import 'package:instabug_flutter/src/utils/screen_loading/screen_loading_manager.dart';
109
import 'package:instabug_flutter_example/src/app_routes.dart';
10+
import 'package:instabug_flutter_example/src/utils/show_messages.dart';
1111
import 'package:instabug_flutter_example/src/widget/nested_view.dart';
12+
import 'package:instabug_http_client/instabug_http_client.dart';
1213

1314
import 'src/native/instabug_flutter_example_method_channel.dart';
1415
import 'src/widget/instabug_button.dart';
1516
import 'src/widget/instabug_clipboard_input.dart';
1617
import 'src/widget/instabug_text_field.dart';
17-
import 'package:instabug_flutter/src/utils/screen_loading/screen_loading_manager.dart';
18-
1918
import 'src/widget/section_title.dart';
2019

21-
part 'src/screens/crashes_page.dart';
22-
23-
part 'src/screens/complex_page.dart';
24-
25-
part 'src/screens/apm_page.dart';
26-
27-
part 'src/screens/screen_capture_premature_extension_page.dart';
28-
29-
part 'src/screens/screen_loading_page.dart';
30-
31-
part 'src/screens/my_home_page.dart';
32-
20+
part 'src/components/animated_box.dart';
3321
part 'src/components/fatal_crashes_content.dart';
34-
35-
part 'src/components/non_fatal_crashes_content.dart';
36-
22+
part 'src/components/flows_content.dart';
3723
part 'src/components/network_content.dart';
38-
24+
part 'src/components/non_fatal_crashes_content.dart';
3925
part 'src/components/page.dart';
40-
26+
part 'src/components/screen_render.dart';
4127
part 'src/components/traces_content.dart';
42-
43-
part 'src/components/flows_content.dart';
28+
part 'src/components/ui_traces_content.dart';
29+
part 'src/screens/apm_page.dart';
30+
part 'src/screens/complex_page.dart';
31+
part 'src/screens/crashes_page.dart';
32+
part 'src/screens/my_home_page.dart';
33+
part 'src/screens/screen_capture_premature_extension_page.dart';
34+
part 'src/screens/screen_loading_page.dart';
35+
part 'src/screens/screen_render_page.dart';
36+
part 'src/components/apm_switch.dart';
37+
part 'src/components/screen_render_switch.dart';
4438

4539
void main() {
4640
runZonedGuarded(

0 commit comments

Comments
 (0)