braze-inc / braze-flutter-sdk

Public repo for the Braze Flutter SDK
Other
15 stars 29 forks source link

StrictMode DiskReadViolation reported several times #66

Closed radivojeostojic closed 2 weeks ago

radivojeostojic commented 2 months ago

During testing of our Android application in StrictMode, we noticed increased number of DiskReadViolation of our MainThread between 400ms and 2000ms.

Sample log:

03-18 10:30:14.566 30136 30136 D StrictMode:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
03-18 10:30:14.568 30136 30136 D StrictMode: StrictMode policy violation; ~duration=1098 ms: android.os.strictmode.DiskReadViolation
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1504)
03-18 10:30:14.568 30136 30136 D StrictMode:    at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:251)
03-18 10:30:14.568 30136 30136 D StrictMode:    at java.io.File.exists(File.java:815)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:653)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:644)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:600)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:809)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:437)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:179)
03-18 10:30:14.568 30136 30136 D StrictMode:    at com.braze.configuration.RuntimeAppConfigurationProvider.<init>(SourceFile:2)
03-18 10:30:14.568 30136 30136 D StrictMode:    at com.braze.configuration.CachedConfigurationProvider.<init>(SourceFile:16)
03-18 10:30:14.568 30136 30136 D StrictMode:    at com.braze.brazeplugin.FlutterCachedConfiguration.<init>(FlutterCachedConfiguration.kt:7)
03-18 10:30:14.568 30136 30136 D StrictMode:    at com.braze.brazeplugin.BrazePlugin.initPlugin(BrazePlugin.kt:48)
03-18 10:30:14.568 30136 30136 D StrictMode:    at com.braze.brazeplugin.BrazePlugin.onAttachedToEngine(BrazePlugin.kt:61)
03-18 10:30:14.568 30136 30136 D StrictMode:    at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.add(FlutterEngineConnectionRegistry.java:146)
03-18 10:30:14.568 30136 30136 D StrictMode:    at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:44)
03-18 10:30:14.568 30136 30136 D StrictMode:    at com.gopuff.godrive2.staging.MainActivity.configureFlutterEngine(MainActivity.kt:40)
03-18 10:30:14.568 30136 30136 D StrictMode:    at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:213)
03-18 10:30:14.568 30136 30136 D StrictMode:    at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:634)
03-18 10:30:14.568 30136 30136 D StrictMode:    at com.gopuff.godrive2.staging.MainActivity.onCreate(MainActivity.kt:56)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.Activity.performCreate(Activity.java:7327)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.Activity.performCreate(Activity.java:7318)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3096)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3259)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1950)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.os.Handler.dispatchMessage(Handler.java:106)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.os.Looper.loop(Looper.java:214)
03-18 10:30:14.568 30136 30136 D StrictMode:    at android.app.ActivityThread.main(ActivityThread.java:7073)
03-18 10:30:14.568 30136 30136 D StrictMode:    at java.lang.reflect.Method.invoke(Native Method)
03-18 10:30:14.568 30136 30136 D StrictMode:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
03-18 10:30:14.568 30136 30136 D StrictMode:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)


StrictMode policy violation; ~duration=2025 ms: android.os.strictmode.DiskReadViolation
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1504)
03-15 13:54:48.618 29151 29151 D StrictMode:    at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:251)
03-15 13:54:48.618 29151 29151 D StrictMode:    at java.io.File.exists(File.java:815)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:653)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:644)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:600)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:809)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:437)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:179)
03-15 13:54:48.618 29151 29151 D StrictMode:    at com.braze.configuration.RuntimeAppConfigurationProvider.<init>(SourceFile:2)
03-15 13:54:48.618 29151 29151 D StrictMode:    at com.braze.configuration.CachedConfigurationProvider.<init>(SourceFile:16)
03-15 13:54:48.618 29151 29151 D StrictMode:    at com.braze.brazeplugin.FlutterCachedConfiguration.<init>(FlutterCachedConfiguration.kt:7)
03-15 13:54:48.618 29151 29151 D StrictMode:    at com.braze.brazeplugin.BrazePlugin.initPlugin(BrazePlugin.kt:48)
03-15 13:54:48.618 29151 29151 D StrictMode:    at com.braze.brazeplugin.BrazePlugin.onAttachedToEngine(BrazePlugin.kt:61)
03-15 13:54:48.618 29151 29151 D StrictMode:    at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.add(FlutterEngineConnectionRegistry.java:146)
03-15 13:54:48.618 29151 29151 D StrictMode:    at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:44)
03-15 13:54:48.618 29151 29151 D StrictMode:    at com.gopuff.godrive2.staging.MainActivity.configureFlutterEngine(MainActivity.kt:40)
03-15 13:54:48.618 29151 29151 D StrictMode:    at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:213)
03-15 13:54:48.618 29151 29151 D StrictMode:    at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:634)
03-15 13:54:48.618 29151 29151 D StrictMode:    at com.gopuff.godrive2.staging.MainActivity.onCreate(MainActivity.kt:56)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.Activity.performCreate(Activity.java:7327)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.Activity.performCreate(Activity.java:7318)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3096)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3259)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1950)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.os.Handler.dispatchMessage(Handler.java:106)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.os.Looper.loop(Looper.java:214)
03-15 13:54:48.618 29151 29151 D StrictMode:    at android.app.ActivityThread.main(ActivityThread.java:7073)
03-15 13:54:48.618 29151 29151 D StrictMode:    at java.lang.reflect.Method.invoke(Native Method)
03-15 13:54:48.618 29151 29151 D StrictMode:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
03-15 13:54:48.618 29151 29151 D StrictMode:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
03-15 13:54:48.619 29151 29151 D StrictMode: StrictMode policy violation; ~duration=1709 ms: android.os.strictmode.DiskReadViolation

Tested on multiple Android devices, current log is from the Android 12 (Samsung s8+)

Flutter doctor output:


[!] Flutter (Channel [user-branch], 3.16.9, on macOS 14.0 23A344 darwin-arm64, locale en-RS)
    ! Flutter version 3.16.9 on channel [user-branch] at /Users/radivojeostojic/Documents/development/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.17.6/libexec/bin/dart, which is not inside your current Flutter SDK checkout at
      /Users/radivojeostojic/Documents/development/flutter. Consider adding /Users/radivojeostojic/Documents/development/flutter/bin to the front of your path.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision 41456452f2 (8 weeks ago), 2024-01-25 10:06:23 -0800
    • Engine revision f40e976bed
    • Dart version 3.2.6
    • DevTools version 2.28.5
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/radivojeostojic/Library/Android/sdk
    • Platform android-34, build-tools 33.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.68.1)
    • VS Code at /Users/radivojeostojic/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] Connected device (4 available)
    • SM G955U1 (mobile)         • 988bdc37395638324a                   • android-arm64  • Android 9 (API 28)
    • iPhone 15 Pro Max (mobile) • 9D762A9B-159B-4456-B8E3-99ECD5B453D0 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 14.0 23A344 darwin-arm64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 122.0.6261.129
    ! Error: Browsing on the local area network for Radivoje’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Braze SDK version: 8.0.0

vanessaland commented 1 month ago

Hi @radivojeostojic, thank you for raising this and providing the supporting information. Our team will be further investigating into this. We will update this thread with progress going forward regarding this issue.

Thank you!

vanessaland commented 2 weeks ago

Thank you for raising this @radivojeostojic! This fix has been released in Flutter SDK version 10.0.0.

I'll be closing this issue for now, but feel free to re-open if you are still having issues regarding this. Thank you!