You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The app completely crashes with no error logs. Threw me for a loop for a few hours until I pinpointed the crash and problem with my code.
Solution
Ideally if you feed a non-image file into the blurhash.encode it should check first if it is a valid image and then throw a console.error if it isn't, instead of crashing the app with no logs.
Describe alternatives you've considered
I added the following function:
import*asmimefrom"react-native-mime-types"exportasyncfunctionisValidImage(url: string){/*For some reason on Android, fetch - blob doesn't work and returns no mimetype, but it works on iOSIn order to check on android, use the mime.lookup(url) which coincidentally only works on Android and not iOS*/try{constresponse=awaitfetch(url)constblob=awaitresponse.blob()returnblob.type.startsWith("image/")||mime.lookup(url).toString().startsWith("image")}catch(error){console.error("Blurhash doesn't work for files that aren't images!")returnfalse}}
The text was updated successfully, but these errors were encountered:
Problem
If you feed a non-image file into Blurhash.encode:
The app completely crashes with no error logs. Threw me for a loop for a few hours until I pinpointed the crash and problem with my code.
Solution
Ideally if you feed a non-image file into the
blurhash.encode
it should check first if it is a valid image and then throw aconsole.error
if it isn't, instead of crashing the app with no logs.Describe alternatives you've considered
I added the following function:
The text was updated successfully, but these errors were encountered: