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

React.Image doesn't support animated GIFs on iOS #24

Closed
zertosh opened this issue Feb 1, 2015 · 24 comments
Closed

React.Image doesn't support animated GIFs on iOS #24

zertosh opened this issue Feb 1, 2015 · 24 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@zertosh
Copy link
Member

zertosh commented Feb 1, 2015

Seems like it only shows the first frame. I'm loading http addresses, not local or static image resources - not sure if that makes a difference.

@vjeux
Copy link
Contributor

vjeux commented Feb 1, 2015

cc @nicklockwood

@a2
Copy link
Contributor

a2 commented Feb 1, 2015

iOS image views do not natively support animated GIFs. There are 3rd party libraries out there that convert animated GIFs into native image sequences. I'll look into support for this soon. 👍

@a2 a2 changed the title React.Image doesn't animate gifs React.Image doesn't support animated GIFs on iOS Feb 1, 2015
@zertosh
Copy link
Member Author

zertosh commented Feb 1, 2015

Thanks @a2 and @vjeux!

@frantic
Copy link
Contributor

frantic commented Feb 2, 2015

@a2 How about SVGs too? :)

@zertosh
Copy link
Member Author

zertosh commented Feb 4, 2015

Looks like it was fixed in 6153fff. Thanks!

@zertosh
Copy link
Member Author

zertosh commented Feb 4, 2015

Yeah it's workin'
react-native-image-gifs

@a2
Copy link
Contributor

a2 commented Feb 4, 2015

@zertosh 👍
@frantic, I'd like to leave out SVG parsing for now because it adds a lot of unnecessary bloat to the binary. Perhaps a plug-in would be a good fit for this?

GIF support is landed so I'm going to close this now. 🙇

@a2 a2 closed this as completed Feb 4, 2015
@vjeux
Copy link
Contributor

vjeux commented Feb 4, 2015

Yup, SVG seems more suited for a different target rather than the Image component

@zertosh
Copy link
Member Author

zertosh commented Feb 4, 2015

I think I misunderstood the mission/role of react-native. I can't find it in the docs, but I walked away with the idea that Components would map closely to their native counterpart. So, if UIImage doesn't support gifs, but <Image /> does, then I must be mistaken. Does this also mean that the Andriod version of <Image /> will support gifs? What if there are components that can't reconcile their feature set across platforms? I understand that the goal is not to "write-once run everywhere", but does this mean that core components will diverge significantly between platforms? I'm not complaining - I like the gif support - I'm just looking for clarification.

@vjeux
Copy link
Contributor

vjeux commented Feb 4, 2015

@zertosh very good question :) Here's a very nuanced answer.

In my mind, the reason why the "write once, run everywhere" approaches fail is that your only possibility is to use the cross platform components. You don't have the ability to use the native components from the platform.

With React native, it's a requirement to be able to use the native elements from the platform, be Navigator for iOS, Drawer for Android or <video> on web. But, that doesn't mean that we should share nothing.

There's a very interesting property which is that if you don't have the same building blocks (div, View...) then you CANNOT share ANY line of UI code. A concrete example is that we wanted to share a <Timestamp> component and we had to copy and paste it because span did not exist in React native context.

So, we decided to have some core components (View, Image, ScrollView, ...) that work on all the platforms and are a lowest common denominator that works everywhere. I was extremely surprised but it turns out that this subset is actually pretty large. The innovative things from platform to platform are not much in the low level details like border or background color, but in high level components.

Right now, there are some attributes for those that are platform specific like alwaysBounceVertical for ScrollView. So we're probably going to split it into two components: <ScrollView> that is the subset that works everywhere and <ScrollViewIOS> that contains platform specific attributes.

There's still a lot of unknowns in the API design that we want to figure out :)

@zertosh
Copy link
Member Author

zertosh commented Feb 4, 2015

@vjeux: Thank you for the detailed answer. I'm happy to hear that baseline and platform specific components are being considered. Feels like a very web thing to do. It'll be interesting to see how the polyfill/shim world develops around this, and to what extent devs will take a progressive enhancement approach to building cross-platform components (if they do at all).

@vjeux
Copy link
Contributor

vjeux commented Feb 5, 2015

We're in the middle of our first conversion from an app written on iOS to Android. Here's the setup that we decided on so far.

All the iOS specific implementations have a barely functional and super ugly version for Android that only uses core components such as View and Text. The goal of those "polyfills" is such that the app compiles and runs in all the platforms, but there are ugly red components everywhere. Then, you can start figuring out the best solution finding an Android-friendly way to deal with those iOS components.

You'll probably end up rewriting a large part of your UI in order to make it look and feel good on Android, but you can do that iteratively and not having to fix all of them before anything even compiles.

This is still a very new territory for us and this may or may not be a viable solution :p

@wong2
Copy link

wong2 commented Apr 21, 2015

does defaultSource support GIFs? I tried and it seems not working

@nicklockwood
Copy link
Contributor

No, it probably doesn't. I'll file a task to fix that.

@wong2
Copy link

wong2 commented Apr 21, 2015

@nicklockwood thanks, waiting for this

@wong2
Copy link

wong2 commented May 18, 2015

@nicklockwood any updates on this? 😄

@SelmanKahya
Copy link

Is GIF still supported? I am trying to display an animated GIF as follows:
<Image source={require('image!sandglass')} />

PNG works just fine, but I am getting the following error when I try to render animated GIF in my view. Restarting the package manager doesn't help. Any ideas?

screen shot 2015-05-31 at 12 57 11 am

@ide
Copy link
Contributor

ide commented May 31, 2015

AFAIK remote gifs are supported. Try a URL.

@nicklockwood
Copy link
Contributor

Gifs should work for both remote and local images, but there might be an issue using them with the require() syntax. Try just using the file name (including extension) as the uri value.

@SelmanKahya
Copy link

Yea, using uri worked fine, thanks.
<Image style={styles.gif} source={{ uri: 'test.gif' }} />

@magicismight
Copy link
Contributor

This
<Image source={{uri: 'load.gif'}} style={{height: 40, width: 40}} />
will throw an exception in RCTGIFImage.m
<Error>: ImageIO: CGImageSourceGetType image source parameter is nil

harrykiselev pushed a commit to harrykiselev/react-native that referenced this issue Aug 5, 2015
Keep use of "ChatConstants" consistent
@ghost
Copy link

ghost commented Sep 21, 2015

Confirming the syntax @SelmanH used to load a gif works when image added in Copy Bundle Resources build phase for the main target in Xcode.

@miracle2k
Copy link

Gifs animated fine when read from a URL. If I load the same image locally (via Copy Bundle Resources), it is displayed, but does not animate anymore:

 <Image style={{height: 128, width: 170, marginTop: 20}}
      source={{ uri: 'alphabets-children-5-277623.gif' }} />

dustturtle added a commit to dustturtle/react-native that referenced this issue Jul 6, 2016
…crash on simulator, on device I got nothing but app freezed)!

My app has an old version of JSONKit which is still using MRC. I think JSONKit is not needed if system version is available. Kicking out of JSONKit will make react native stronger.
Crash stack:
* thread facebook#11: tid = 0xbd672f, 0x000000010a10edeb imobii-waiqin`jk_encode_add_atom_to_buffer(encodeState=0x00007f9b820a1000, objectPtr=22 key/value pairs) + 16971 at JSONKit.m:2807, name = 'com.facebook.React.JavaScript', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x000000010a10edeb imobii-waiqin`jk_encode_add_atom_to_buffer(encodeState=0x00007f9b820a1000, objectPtr=22 key/value pairs) + 16971 at JSONKit.m:2807
    frame facebook#1: 0x000000010a10ef67 imobii-waiqin`jk_encode_add_atom_to_buffer(encodeState=0x00007f9b820a1000, objectPtr=2 key/value pairs) + 17351 at JSONKit.m:2811
    frame facebook#2: 0x000000010a10ef67 imobii-waiqin`jk_encode_add_atom_to_buffer(encodeState=0x00007f9b820a1000, objectPtr=25 key/value pairs) + 17351 at JSONKit.m:2811
    frame facebook#3: 0x000000010a10e768 imobii-waiqin`jk_encode_add_atom_to_buffer(encodeState=0x00007f9b820a1000, objectPtr=@"3 elements") + 15304 at JSONKit.m:2778
  * frame facebook#4: 0x000000010a10a26a imobii-waiqin`-[JKSerializer serializeObject:options:encodeOption:block:delegate:selector:error:](self=0x00007f9b831fbc80, _cmd="serializeObject:options:encodeOption:block:delegate:selector:error:", object=@"3 elements", optionFlags=0, encodeOption=10, block=0x0000000000000000, delegate=0x0000000000000000, selector=<no value available>, error=domain: class name = NSInvocation - code: 0) + 2250 at JSONKit.m:2876
    frame facebook#5: 0x000000010a109992 imobii-waiqin`+[JKSerializer serializeObject:options:encodeOption:block:delegate:selector:error:](self=JKSerializer, _cmd="serializeObject:options:encodeOption:block:delegate:selector:error:", object=@"3 elements", optionFlags=0, encodeOption=10, block=0x0000000000000000, delegate=0x0000000000000000, selector=<no value available>, error=domain: class name = NSInvocation - code: 0) + 178 at JSONKit.m:2831
    frame facebook#6: 0x000000010a10f700 imobii-waiqin`-[NSArray(self=@"3 elements", _cmd="JSONStringWithOptions:error:", serializeOptions=0, error=domain: class name = NSInvocation - code: 0) JSONStringWithOptions:error:] + 112 at JSONKit.m:2985
    frame facebook#7: 0x000000010ac13c02 imobii-waiqin`_RCTJSONStringifyNoRetry(jsonObject=@"3 elements", error=domain: class name = NSInvocation - code: 0) + 338 at RCTUtils.m:49
    frame facebook#8: 0x000000010ac13990 imobii-waiqin`RCTJSONStringify(jsonObject=@"3 elements", error=0x0000000000000000) + 128 at RCTUtils.m:77
    frame facebook#9: 0x000000010ab5fdfa imobii-waiqin`__27-[RCTContextExecutor setUp]_block_invoke_2(.block_descriptor=<unavailable>, moduleName=@"UIManager") + 218 at RCTContextExecutor.m:363
    frame facebook#10: 0x00000001134495cc CoreFoundation`__invoking___ + 140
    frame facebook#11: 0x000000011344941e CoreFoundation`-[NSInvocation invoke] + 286
    frame facebook#12: 0x000000010db13db3 JavaScriptCore`JSC::ObjCCallbackFunctionImpl::call(JSContext*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**) + 451
    frame facebook#13: 0x000000010db13926 JavaScriptCore`JSC::objCCallbackFunctionCallAsFunction(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**) + 262
    frame facebook#14: 0x000000010db14bad JavaScriptCore`long long JSC::APICallbackFunction::call<JSC::ObjCCallbackFunction>(JSC::ExecState*) + 573
    frame facebook#15: 0x000000010dade340 JavaScriptCore`JSC::LLInt::setUpCall(JSC::ExecState*, JSC::Instruction*, JSC::CodeSpecializationKind, JSC::JSValue, JSC::LLIntCallLinkInfo*) + 528
    frame facebook#16: 0x000000010dae535d JavaScriptCore`llint_entry + 22900
    frame facebook#17: 0x000000010dadf7d9 JavaScriptCore`vmEntryToJavaScript + 326
    frame facebook#18: 0x000000010d9b1959 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 169
    frame facebook#19: 0x000000010d9985ad JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 493
    frame facebook#20: 0x000000010d76cb7e JavaScriptCore`JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 62
    frame facebook#21: 0x000000010d929a55 JavaScriptCore`JSC::callGetter(JSC::ExecState*, JSC::JSValue, JSC::JSValue) + 149
    frame facebook#22: 0x000000010dad49fb JavaScriptCore`llint_slow_path_get_by_id + 2203
    frame facebook#23: 0x000000010dae22f0 JavaScriptCore`llint_entry + 10503
    frame facebook#24: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#25: 0x000000010dae52fd JavaScriptCore`llint_entry + 22804
    frame facebook#26: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#27: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#28: 0x000000010dae52fd JavaScriptCore`llint_entry + 22804
    frame facebook#29: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#30: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#31: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#32: 0x000000010dae552a JavaScriptCore`llint_entry + 23361
    frame facebook#33: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#34: 0x000000010dae5368 JavaScriptCore`llint_entry + 22911
    frame facebook#35: 0x000000010dadf7d9 JavaScriptCore`vmEntryToJavaScript + 326
    frame facebook#36: 0x000000010d9b1959 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 169
    frame facebook#37: 0x000000010d998264 JavaScriptCore`JSC::Interpreter::execute(JSC::ProgramExecutable*, JSC::ExecState*, JSC::JSObject*) + 10404
    frame facebook#38: 0x000000010d7a8786 JavaScriptCore`JSC::evaluate(JSC::ExecState*, JSC::SourceCode const&, JSC::JSValue, WTF::NakedPtr<JSC::Exception>&) + 470
    frame facebook#39: 0x000000010d9f6fb8 JavaScriptCore`JSEvaluateScript + 424
    frame facebook#40: 0x000000010ab6379e imobii-waiqin`__68-[RCTContextExecutor executeApplicationScript:sourceURL:onComplete:]_block_invoke.264(.block_descriptor=<unavailable>) + 414 at RCTContextExecutor.m:589
    frame facebook#41: 0x000000010ab63262 imobii-waiqin`__68-[RCTContextExecutor executeApplicationScript:sourceURL:onComplete:]_block_invoke(.block_descriptor=<unavailable>) + 498 at RCTContextExecutor.m:589
    frame facebook#42: 0x000000010ab63df8 imobii-waiqin`-[RCTContextExecutor executeBlockOnJavaScriptQueue:](self=0x00007f9b832f6040, _cmd="executeBlockOnJavaScriptQueue:", block=0x00007f9b80c92970) + 248 at RCTContextExecutor.m:627
    frame facebook#43: 0x000000010eb1d7a7 Foundation`__NSThreadPerformPerform + 283
    frame facebook#44: 0x0000000113486301 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame facebook#45: 0x000000011347c22c CoreFoundation`__CFRunLoopDoSources0 + 556
    frame facebook#46: 0x000000011347b6e3 CoreFoundation`__CFRunLoopRun + 867
    frame facebook#47: 0x000000011347b0f8 CoreFoundation`CFRunLoopRunSpecific + 488
    frame facebook#48: 0x000000010ab5e41b imobii-waiqin`+[RCTContextExecutor runRunLoopThread](self=RCTContextExecutor, _cmd="runRunLoopThread") + 363 at RCTContextExecutor.m:284
    frame facebook#49: 0x000000010ebc012b Foundation`__NSThread__start__ + 1198
    frame facebook#50: 0x00000001140869b1 libsystem_pthread.dylib`_pthread_body + 131
    frame facebook#51: 0x000000011408692e libsystem_pthread.dylib`_pthread_start + 168
    frame facebook#52: 0x0000000114084385 libsystem_pthread.dylib`thread_start + 13
@sudhanshu6247
Copy link

I am having just opposite problem. In my case gif is not getting loaded from url but when I load it from local it works fine.

<Image style={{maxWidth: deviceWidth-112, resizeMode:'contain', maxHeight: 300}} source={{uri: 'https://s3-ap-southeast-1.amazonaws.com/healthmirdev/channel/gifs/anxiety.gif'}}  />

@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests