Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Error Handling #25

Closed
msuddaby opened this issue Aug 13, 2024 · 2 comments
Closed

No Error Handling #25

msuddaby opened this issue Aug 13, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@msuddaby
Copy link

msuddaby commented Aug 13, 2024

🐛 Bug Report

The SDK currently lacks error handling for various problems. Currently, if a GIPHY ID which has been removed from the platform is passed in to GiphyMediaView, the media appears blank on iOS and the app completely crashes on Android when the media is loaded. There does not appear to be any way to handle these errors.

To Reproduce

  1. Pass in an invalid / removed media ID to GiphyMediaView()
const mediaId = "Jz1ytd47COvefoPZ92"
...
return GiphyMediaView(
              mediaId: mediaId,
              renditionType: GiphyRendition.original,
              resizeMode: GiphyResizeMode.contain,
            );

Expected behavior

Have some way to handle what happens when the media is invalid. Packages like CachedNetworkImage have onError and errorListener callbacks so you can display something else when an error occurs.

Actual Behavior

On iOS, the image does not appear. On Android, the entire app crashes with this error:

/com.giphy.sdk.core.network.engine.NetworkSession( 4962): Unable to perform network request for url=https://api.giphy.com/v1/gifs/Jz1ytd47COvefoPZ92?api_key={{APIKEY}}&random_id={{RANDOMID}}
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): com.giphy.sdk.core.network.engine.ApiException
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at com.giphy.sdk.core.network.engine.DefaultNetworkSession.readJsonResponse(DefaultNetworkSession.kt:182)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at com.giphy.sdk.core.network.engine.DefaultNetworkSession.postStringConnection$lambda$1(DefaultNetworkSession.kt:103)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at com.giphy.sdk.core.network.engine.DefaultNetworkSession.$r8$lambda$oBss5ASDiV2Y1BNSUq9jQ38G9OQ(Unknown Source:0)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at com.giphy.sdk.core.network.engine.DefaultNetworkSession$$ExternalSyntheticLambda0.call(Unknown Source:16)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at com.giphy.sdk.core.threading.ApiTask.executeImmediately(ApiTask.kt:83)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at com.giphy.sdk.core.network.api.GPHApiClient.queryStringConnectionWrapper$lambda$18(GPHApiClient.kt:261)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at com.giphy.sdk.core.network.api.GPHApiClient.$r8$lambda$DdNnpUDed-WszBziyT-grfzG6dY(Unknown Source:0)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at com.giphy.sdk.core.network.api.GPHApiClient$$ExternalSyntheticLambda3.call(Unknown Source:12)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at com.giphy.sdk.core.threading.ApiTask.executeAsyncTask$lambda$3(ApiTask.kt:55)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at com.giphy.sdk.core.threading.ApiTask.$r8$lambda$ZQwiNZCGta7iEaxrS-s5VxkqxaI(Unknown Source:0)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at com.giphy.sdk.core.threading.ApiTask$$ExternalSyntheticLambda3.run(Unknown Source:4)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
E/com.giphy.sdk.core.network.engine.NetworkSession( 4962): 	at java.lang.Thread.run(Thread.java:1012)
D/AndroidRuntime( 4962): Shutting down VM
E/AndroidRuntime( 4962): FATAL EXCEPTION: main
E/AndroidRuntime( 4962): Process: com.example.exampleapp, PID: 4962
E/AndroidRuntime( 4962): java.lang.NullPointerException: println needs a message
E/AndroidRuntime( 4962): 	at android.util.Log.println_native(Native Method)
E/AndroidRuntime( 4962): 	at android.util.Log.d(Log.java:173)
E/AndroidRuntime( 4962): 	at com.giphy.giphy_flutter_sdk.GiphyFlutterMediaView$setMediaWithId$1.invoke(GiphyFlutterMediaView.kt:100)
E/AndroidRuntime( 4962): 	at com.giphy.giphy_flutter_sdk.GiphyFlutterMediaView$setMediaWithId$1.invoke(GiphyFlutterMediaView.kt:96)
E/AndroidRuntime( 4962): 	at com.giphy.sdk.core.GPHCore$gifById$1.onComplete(GPHCore.kt:22)
E/AndroidRuntime( 4962): 	at com.giphy.sdk.core.GPHCore$gifById$1.onComplete(GPHCore.kt:20)
E/AndroidRuntime( 4962): 	at com.giphy.sdk.core.threading.ApiTask.executeAsyncTask$lambda$3$lambda$2(ApiTask.kt:70)
E/AndroidRuntime( 4962): 	at com.giphy.sdk.core.threading.ApiTask.$r8$lambda$hdC_kOTEIApTyjxcE-uc0RgvCdY(Unknown Source:0)
E/AndroidRuntime( 4962): 	at com.giphy.sdk.core.threading.ApiTask$$ExternalSyntheticLambda2.run(Unknown Source:4)
E/AndroidRuntime( 4962): 	at android.os.Handler.handleCallback(Handler.java:959)
E/AndroidRuntime( 4962): 	at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime( 4962): 	at android.os.Looper.loopOnce(Looper.java:232)
E/AndroidRuntime( 4962): 	at android.os.Looper.loop(Looper.java:317)
E/AndroidRuntime( 4962): 	at android.app.ActivityThread.main(ActivityThread.java:8705)
E/AndroidRuntime( 4962): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 4962): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
E/AndroidRuntime( 4962): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
D/EGL_emulation( 4962): app_time_stats: avg=8.54ms min=0.96ms max=144.54ms count=51
I/active.teamapp4( 4962): Thread[2,tid=4964,WaitingInMainSignalCatcherLoop,Thread*=0xb400007e1ca286f0,peer=0x14002238,"Signal Catcher"]: reacting to signal 3
I/active.teamapp4( 4962): 
I/active.teamapp4( 4962): Wrote stack traces to tombstoned
Lost connection to device.

Your Environment

  • Giphy Flutter SDK version: ^0.1.2
  • Dart SDK version: 3.4.4 (stable) (Wed Jun 12 15:54:31 2024 +0000) on "macos_arm64"
  • Flutter SDK version: Flutter 3.22.3 • channel stable
  • Platform(s) (iOS, Android, or both?): both.
  • Device info (Simulator/Device? OS version? Debug/Release?): Crash happening on Pixel 8 Pro API 35 emulator. Debug mode.

Reproducible Demo

Copy the lines of code above into a demo app with the GIPHY SDK set up. The provided media ID is one that was available before, but removed by the platform (I assume). attempting to visit that media ID brings up a 404.

@msuddaby msuddaby added the bug Something isn't working label Aug 13, 2024
@ALexanderLonsky
Copy link
Contributor

Hey @msuddaby,
Thanks for flagging this!
Please try the new version: v1.0.0.
You can find an example on how to use the new callback here: link

@msuddaby
Copy link
Author

Hey @msuddaby, Thanks for flagging this! Please try the new version: v1.0.0. You can find an example on how to use the new callback here: link

Awesome work, thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants