Skip to content

Commit df90224

Browse files
committed
remove debugging code
1 parent 5d9484e commit df90224

File tree

3 files changed

+2
-127
lines changed

3 files changed

+2
-127
lines changed

app/src/main/java/com/newrelic/nrvideoproject/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
2020
@Override
2121
protected void onCreate(Bundle savedInstanceState) {
2222
super.onCreate(savedInstanceState);
23-
NRVideoConfiguration config = new NRVideoConfiguration.Builder("AA89bd55fcd6b93884c7ea1acad63fba5a41845428-NRMA")
23+
NRVideoConfiguration config = new NRVideoConfiguration.Builder(BuildConfig.NR_APPLICATION_TOKEN)
2424
.autoDetectPlatform(getApplicationContext())
2525
.withHarvestCycle(60)
2626
.enableLogging()

app/src/main/java/com/newrelic/nrvideoproject/VideoPlayer.java

Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
import androidx.media3.ui.PlayerView;
77
import android.net.Uri;
88
import android.os.Bundle;
9-
import android.os.Handler;
10-
import android.os.Looper;
119
import android.util.Log;
12-
import android.view.View;
13-
import android.widget.Button;
1410
import com.newrelic.videoagent.core.NRVideo;
1511
import com.newrelic.videoagent.core.NRVideoPlayerConfiguration;
1612
import com.newrelic.videoagent.core.NewRelicVideoAgent;
@@ -26,7 +22,6 @@ public class VideoPlayer extends AppCompatActivity {
2622

2723
private ExoPlayer player;
2824
private Integer trackerId;
29-
private boolean isStressingCPU = false;
3025

3126
@Override
3227
protected void onCreate(Bundle savedInstanceState) {
@@ -64,26 +59,7 @@ protected void onDestroy() {
6459
}
6560

6661
private void playVideo(String videoUrl) {
67-
//player = new ExoPlayer.Builder(this).build();
68-
//Create ExoPlayer with custom configuration for easier frame drop detection
69-
androidx.media3.exoplayer.DefaultLoadControl loadControl = new androidx.media3.exoplayer.DefaultLoadControl.Builder()
70-
.setBufferDurationsMs(
71-
500, // Min buffer (very low to stress system)
72-
2000, // Max buffer (low to force frequent loading)
73-
250, // Buffer for playback
74-
500 // Buffer for playback after rebuffer
75-
)
76-
.build();
77-
78-
// Use default renderers factory without the problematic operation mode
79-
androidx.media3.exoplayer.DefaultRenderersFactory renderersFactory =
80-
new androidx.media3.exoplayer.DefaultRenderersFactory(this);
81-
82-
player = new ExoPlayer.Builder(this)
83-
.setLoadControl(loadControl)
84-
.setRenderersFactory(renderersFactory)
85-
.build();
86-
Log.d("VideoPlayer", "ExoPlayer created with LOW BUFFER settings for frame drop detection: " + player.getClass().getSimpleName());
62+
player = new ExoPlayer.Builder(this).build();
8763

8864
Map<String, Object> customAttr = new HashMap<>();
8965
customAttr.put("something", "This is my test title");
@@ -115,93 +91,5 @@ private void playVideo(String videoUrl) {
11591
// Prepare the player.
11692
player.setPlayWhenReady(true);
11793
player.prepare();
118-
119-
// Add button to trigger frame drops for testing
120-
setupFrameDropTestButton();
121-
}
122-
private void setupFrameDropTestButton() {
123-
Button frameDropButton = findViewById(R.id.button_frame_drop_attack);
124-
if (frameDropButton != null) {
125-
frameDropButton.setOnClickListener(new View.OnClickListener() {
126-
@Override
127-
public void onClick(View v) {
128-
ManualFrameDropAttack();
129-
}
130-
});
131-
}
132-
}
133-
private void ManualFrameDropAttack() {
134-
// Attack 1: Saturate ALL threads with MAXIMUM priority
135-
int cores = Runtime.getRuntime().availableProcessors();
136-
for (int i = 0; i < cores * 4; i++) { // 4x oversaturate
137-
new Thread(new Runnable() {
138-
@Override
139-
public void run() {
140-
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
141-
while (isStressingCPU) {
142-
// Most CPU-intensive operations possible
143-
for (int j = 0; j < 10000000; j++) { // 10 million iterations
144-
double result = Math.pow(Math.sin(j), Math.cos(j)) * Math.sqrt(j * Math.PI) * Math.log(j + 1);
145-
}
146-
}
147-
}
148-
}).start();
149-
}
150-
151-
// Attack 2: Memory allocation bomb
152-
new Thread(new Runnable() {
153-
@Override
154-
public void run() {
155-
try {
156-
List<byte[]> memoryBomb = new ArrayList<>();
157-
for (int i = 0; i < 1000; i++) {
158-
memoryBomb.add(new byte[50 * 1024 * 1024]); // 50MB chunks
159-
if (i % 5 == 0) System.gc(); // Frequent GC
160-
}
161-
} catch (OutOfMemoryError e) {
162-
Log.d("VideoPlayer", "Memory bomb successful - OOM triggered");
163-
}
164-
}
165-
}).start();
166-
167-
// Attack 3: Main thread destruction
168-
brutalMainThreadBlocking();
169-
170-
isStressingCPU = true;
171-
172-
// Stop after 20 seconds
173-
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
174-
@Override
175-
public void run() {
176-
isStressingCPU = false;
177-
}
178-
}, 20000);
179-
}
180-
private void brutalMainThreadBlocking() {
181-
final Handler mainHandler = new Handler(Looper.getMainLooper());
182-
final Runnable blocker = new Runnable() {
183-
int iteration = 0;
184-
185-
@Override
186-
public void run() {
187-
if (iteration < 100) {
188-
// Block main thread for 200ms
189-
long startTime = System.currentTimeMillis();
190-
while (System.currentTimeMillis() - startTime < 200) {
191-
// Intensive work on main thread
192-
for (int i = 0; i < 1000000; i++) {
193-
Math.sin(i * Math.PI);
194-
}
195-
}
196-
197-
iteration++;
198-
Log.d("VideoPlayer", "Main thread blocked for 200ms - iteration " + iteration);
199-
200-
// Block again in 100ms
201-
mainHandler.postDelayed(this, 100);
202-
}
203-
}
204-
};
205-
mainHandler.post(blocker);
20694
}
20795
}

app/src/main/res/layout/activity_video_player.xml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,4 @@
1414
app:layout_constraintStart_toStartOf="parent"
1515
app:layout_constraintTop_toTopOf="parent"/>
1616

17-
<Button
18-
android:id="@+id/button_frame_drop_attack"
19-
android:layout_width="match_parent"
20-
android:layout_height="wrap_content"
21-
android:text="Manual Content Drop Frame event trigger"
22-
android:textStyle="bold"
23-
android:backgroundTint="#D32F2F"
24-
android:textColor="#FFFFFF"
25-
android:layout_margin="16dp"
26-
app:layout_constraintBottom_toBottomOf="parent"
27-
app:layout_constraintStart_toStartOf="parent"
28-
app:layout_constraintEnd_toEndOf="parent"/>
29-
3017
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)