Giter Site home page Giter Site logo

apngkit's Introduction

你好,世界 👋

  • 📙 Focusing on Swift & iOS
  • 🔨 Creator of applications and frameworks
  • 🐏 Founder of ObjCCN
  • 🍖 Meat lover

apngkit's People

Contributors

aodhol avatar buzzmusiq avatar carlosdigio avatar cetauri avatar christopherrogers avatar dorofiykolya avatar helloyako avatar jdmcd avatar lumenlunae avatar noppefoxwolf avatar onevcat avatar sidepelican avatar thii avatar tyljohnny avatar w4-hojin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apngkit's Issues

Adding APNGKit project to workplace and build with Xcode 9 beta got error

As title, I build APNGKit project by self, and try to build my project with Xcode 9 beta, it got error like this:

The following binaries use incompatible versions of Swift:
...

Should I change any setting after I upgrade Xcode? My project is using objective-c.

EDIT:

I try to set my app target's setting to:

ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO

It can build success, but run time crash.

Repeatedly push an view controller whose view owned a apng animation view and pop it, app will crash.

This is the occasional problem. And we detected it by our apm system. And finally positioned to the APNGKit. I test the APNGKit's demo, it also has the same problem.

This is the error symbol stack log of APNGKitDemo proj.

Hardware Model:      iPhone7,2
Process:             APNGDemo-iOS [3710]
Path:                /private/var/containers/Bundle/Application/42CDB407-533D-4EA7-8F5D-77F199CBAC8B/APNGDemo-iOS.app/APNGDemo-iOS
Identifier:          com.onevcat.APNGDemo-iOS
Version:             1 (1.0)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.onevcat.APNGDemo-iOS [3835]


Date/Time:           2017-11-07 10:28:59.6368 +0800
Launch Time:         2017-11-07 10:27:52.6125 +0800
OS Version:          iPhone OS 10.3.2 (14F89)
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000109e38000
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
Triggered by Thread:  0

Filtered syslog:
None found

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_platform.dylib      	0x000000018bd20e10 _platform_memmove + 176
1   CoreGraphics                  	0x000000018e0702c0 decode_data + 13144
2   CoreGraphics                  	0x000000018e239720 img_decode_read + 2024
3   CoreGraphics                  	0x000000018e23d490 img_alphamerge_read + 548
4   CoreGraphics                  	0x000000018e2408fc img_data_lock + 6124
5   CoreGraphics                  	0x000000018e23f0b8 CGSImageDataLock + 176
6   CoreGraphics                  	0x000000018e05f1c0 ripc_AcquireImage + 756
7   CoreGraphics                  	0x000000018e2539a4 ripc_DrawImage + 656
8   CoreGraphics                  	0x000000018e243b50 CGContextDrawImageWithOptions + 632
9   QuartzCore                    	0x000000018fe87a8c CA::Render::(anonymous namespace)::create_image_by_rendering+ 105100 (CGImage*, CGColorSpace*, unsigned int, double) + 1068
10  QuartzCore                    	0x000000018fe88960 CA::Render::(anonymous namespace)::create_image_from_rgb_image+ 108896 (CGImage*, CGColorSpace*, unsigned int, double) + 660
11  QuartzCore                    	0x000000018fe874b0 CA::Render::create_image+ 103600 (CGImage*, CGColorSpace*, unsigned int, double) + 876
12  QuartzCore                    	0x000000018fe89238 CA::Render::copy_image+ 111160 (CGImage*, CGColorSpace*, unsigned int, double, double) + 472
13  QuartzCore                    	0x000000018ff87434 -[CALayer+ 1152052 (CALayerPrivate) _copyRenderLayer:layerFlags:commitFlags:] + 480
14  QuartzCore                    	0x000000018fef4a74 CA::Context::commit_layer+ 551540 (CA::Layer*, unsigned int, unsigned int, void*) + 108
15  QuartzCore                    	0x000000018ff7a3a8 CA::Layer::commit_if_needed(CA::Transaction*, void (*)+ 1098664 (CA::Layer*, unsigned int, unsigned int, void*), void*) + 388
16  QuartzCore                    	0x000000018feb39ac x_hash_table_foreach + 72
17  QuartzCore                    	0x000000018ff1d4c0 CA::Transaction::foreach_root(void (*)+ 718016 (CA::Layer*, void*), void*) + 40
18  QuartzCore                    	0x000000018fef5778 CA::Context::commit_transaction+ 554872 (CA::Transaction*) + 1320
19  QuartzCore                    	0x000000018ff1c3ac CA::Transaction::commit+ 713644 () + 504
20  QuartzCore                    	0x000000018ff1ce78 CA::Transaction::observer_callback+ 716408 (__CFRunLoopObserver*, unsigned long, void*) + 120
21  CoreFoundation                	0x000000018cc149a8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
22  CoreFoundation                	0x000000018cc12630 __CFRunLoopDoObservers + 372
23  CoreFoundation                	0x000000018cc12a7c __CFRunLoopRun + 956
24  CoreFoundation                	0x000000018cb42da4 CFRunLoopRunSpecific + 424
25  GraphicsServices              	0x000000018e5ac074 GSEventRunModal + 100
26  UIKit                         	0x0000000192dfd058 UIApplicationMain + 208
27  APNGDemo-iOS                  	0x0000000100097cfc 0x100090000 + 31996
28  libdyld.dylib                 	0x000000018bb5159c start + 4

Swift 5 upgrade

Using Xcode 11 GM with Swift 5 tells me to convert APNGKit to support Swift 5.
I can see only one line of code needs to be changed, will we see an update for that?
Thanks!

image

animation time, no animation on iphone

could i set the total animation time? the total duration time of the apng is 1.5s and when i play the animation on iphone , there is not any animation . when run in simulator , have animation but seems weird, what is the reason? the duration of the apng is too short?

Crash when load a normal png

I'm trying to load a normal png and it crashes libpng error: CgBI: unhandled critical chunk

Is there any way to check if the image is an APNG or normal PNG?

短时间内重复销毁创建ApngImageView会导致crash

修改demo中的代码,执行下面的操作,必会crash

@IBAction func click(_ sender: Any) {
        var i = 0
        while i < 3 {
            i += 1
            DispatchQueue.main.async {
                self.test()
            }
            print("count: \(i) \(NSDate())")
//            Thread.sleep(forTimeInterval: 0.3)
        }
    }
    func test() {
        if let path = image?.path {
            imageView?.stopAnimating()
            imageView?.removeFromSuperview()
            imageView = nil
            let apngImage: APNGImage?
            if path.contains("@2x") {
                apngImage = APNGImage(named: (path as NSString).lastPathComponent, progressive: true)
            } else {
                apngImage = APNGImage(contentsOfFile: path, saveToCache: true, progressive: true)
            }
            imageView = APNGImageView.init(image: apngImage)
            imageView?.frame = CGRect(x: 100, y: 100, width: 200, height: 200)
            view.addSubview(imageView!)
            imageView?.startAnimating()
            print("start")
        }
    }
    

APNGImage always returns nil

a line of code below always returns nil even though I passed apng image:

var image = APNGImage(named: "your_image")

Thanks

Unexpected output result for specific apng files

Hello, I've been using the library for quite a long time, and it's great. Recently I found an issue with specific apng files which leads to and unexpected output when loading the file with the library. There is no different method when loading apng files, it just happen sometimes to specific files.

Here you have a video of the glitch (look at the vertical line created between the letter t and y):
actual-result

And here the expected result:
expected-result

Here you can download all the related files:
apng-bugreport.zip

Thanks

EXC_BAD_ACCESS on setting image

Hey,
many thanks for this project!

Can you give some instructions about how I can set my image for instantiating a APNGImage?

Usually I go with UIImage(named: "my-image-name") and it will go and get the correct resource from Images.xcassets.
Is APNGImage(named: String) looking for resources inside Images.xcassets, similiar to UIImage(named: String)?

I even tried to do work around and adding my image to "Build Phases -> Copy Bundle Resources".

let path = NSBundle.mainBundle().pathForResource("animated2", ofType: "apng")
if let path = path {
      let image2 = APNGImage(contentsOfFile: path)
      apngImageView.image = image2
}

Path seems to be correct: "/Users/[...]/Library/Developer/CoreSimulator/Devices/[...]/MyApp.app/animated2.apng"
Debugger says "image2" is not nil and shows me amount of frames and resolution.
But it always breaks with "EXC_BAD_ACCESS (code=2, ...)" when I'm setting image2 as the image of APNGImageView.

What am I doing wrong?

EDIT:
Okay, if I'm creating APNGItemView programmatically everything works fine.
Is the following right for make it working with interface builder?:

  • Adding UIView to Storyboard
  • Setting custom class to "APNGItemView"
  • Creating an IBOutlet named "apngImageView" (in my case above)

Image isn't showing up

I tried both programmatically and storyboard ways, image simply not on screen. Although if I change APNGImage and APNGImageView to UIImage and UIImageView respectively, it works (w/o animation, of course). What could it be? (APNGKit v1.1.0)

Invalid transparency (compression off, APNG source is valid)

Can't understand the problem. I try to load simple APNG image, it is valid (I've checked it via several browsers). And when I look for it with debug mode enabled, I see normal image too. But on the Simulator and on a real device I see image without transparency, where all semi-transparent pixels are set to white. I can't understand what's the reason of this. Compression is OFF in Xcode, file source has "apng" extension (double checked this). When I tried to load this image via UIImage - I saw the normal picture. What's wrong with me?

P.S. Code is pretty simple.

override func viewDidAppear(_ animated: Bool) {
    let image = APNGImage(named: "scene1")
    let imageView = APNGImageView(image: image)
    view.addSubview(imageView)
}

Here you can see my application frozen with View Debug mode. Normal image in Debug area and broken inside the Simulator...

issue

Environment:
Xcode 8 GM Seed
iOS Simulator - iOS 9.3 / 10.0.1
iPhone 6S - iOS 10.0.1

The first frame is skipped (even when it's not set to skip) when calling startAnimating

The first frame is skipped (even when it's not set to skip) when calling startAnimating and when calling stopAnimating and then startAnimating again, the frame when stop was called is shown briefly.
Attached is a test image with frames red[1], yellow[2], green[3], blue[4].
test_sequence

I resolved this by changing startAnimating function by adding

    guard let image = image else {
        return
    }
    let frameIndex: Int = image.firstFrameHidden ? 1 : 0
    currentFrameIndex = frameIndex
    let frame = image.next(currentIndex: currentFrameIndex)
    currentFrameDuration = frame.duration
    updateContents(frame.image)

see https://github.com/imbrig/APNGKit/commit/0b003f19e77a9e51881dbc83ebfdb62fb3a478fb

Podspec

Update podspec for Swift 4.2

deinit crash for iOS

hi 猫神

我在 deinit 时手动 调用stopAnimating(), 偶现 crash , 概率比较高, 控制台可以明显的看到释放代码执行了, 我将 APNGImageView 用于 CollocationView 中

释放的代码:
deinit {
stopAPNG()
}

func stopAPNG() {
if let arFilterAPNGView = arFilterAPNGView {
GCDUtils.main({
print("(Thread.current) ---------------- arFilterAPNGView")
arFilterAPNGView.stopAnimating()
self.arFilterAPNGView = nil
})
}
}

crash时 控制台的 堆栈

  • thread #21, queue = 'gcdTimerQueue'
    frame #0: 0x00000001817958e8 libsystem_kernel.dylib__ulock_wait + 8 frame #1: 0x0000000104997300 libdispatch.dylib_dispatch_ulock_wait + 48
    frame #2: 0x0000000104997428 libdispatch.dylib_dispatch_thread_event_wait_slow + 36 frame #3: 0x000000010497e230 libdispatch.dylib_dispatch_barrier_sync_f_slow + 240
    frame #4: 0x0000000103f797ac APNGKitAPNGImageView.(startAnimating() -> ()).(closure #1) [inlined] function signature specialization <Arg[0] = Owned To Guaranteed> of APNGKit.APNGImageView.(startAnimating () -> ()).(closure #1) at APNGImageView.swift:185 [opt] frame #5: 0x0000000103f79704 APNGKitAPNGImageView.(startAnimating() -> ()).(closure #1) at APNGImageView.swift:184 [opt]
    frame #6: 0x0000000103f7f140 APNGKit`GCDTimer.(Event.setter).(closure #1) [inlined] function signature specialization <Arg[0] = Owned To Guaranteed> of APNGKit.GCDTimer.(self=) -> ()).(closure #1) at GCDTimer.swift:66 [opt]
    • frame #7: 0x0000000103f7f114 APNGKitGCDTimer.(Event.setter).(closure #1) at GCDTimer.swift:65 [opt] frame #8: 0x000000010496da10 libdispatch.dylib_dispatch_client_callout + 16
      frame #9: 0x0000000104979a84 libdispatch.dylib_dispatch_continuation_pop + 552 frame #10: 0x00000001049881f8 libdispatch.dylib_dispatch_source_latch_and_call + 204
      frame #11: 0x000000010496fa60 libdispatch.dylib_dispatch_source_invoke + 828 frame #12: 0x000000010497b128 libdispatch.dylib_dispatch_queue_serial_drain + 692
      frame #13: 0x0000000104971634 libdispatch.dylib_dispatch_queue_invoke + 852 frame #14: 0x000000010497d630 libdispatch.dylib_dispatch_root_queue_drain + 552
      frame #15: 0x000000010497d39c libdispatch.dylib_dispatch_worker_thread3 + 140 frame #16: 0x000000018185b100 libsystem_pthread.dylib_pthread_wqthread + 1096
      frame #17: 0x000000018185acac libsystem_pthread.dylib`start_wqthread + 4

Project Bitcode issue

In out project, we setting the OTHER_CFLAGS to -fembed-bitcode but it show error:

Showing All Errors Only
ld: bitcode bundle could not be generated because '.../Build/Products/Debug-iphoneos/APNGKit/APNGKit.framework/APNGKit' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build for architecture arm64

Is any setting missing or APNGKit didn't support bitcode?

App crash when showing apng image view on each collection view cell

I created a collection view, each collection cell contains apng image view, after scrolling the collection view from left to right the app crashes.

ERROR
#0. Crashed: com.apple.main-thread
0 libsystem_platform.dylib 0x1bbf06c6 _platform_memmove + 37
1 CoreGraphics 0x1d5639af decode_data + 10762
2 CoreGraphics 0x1d6e9471 img_decode_read + 226
3 CoreGraphics 0x1d6eca25 img_alphamerge_read + 382
4 CoreGraphics 0x1d6efc25 img_data_lock + 6540
5 CoreGraphics 0x1d6ee261 CGSImageDataLock + 116
6 CoreGraphics 0x1d555fa7 ripc_AcquireImage + 632
7 CoreGraphics 0x1d701975 ripc_DrawImage + 648
8 CoreGraphics 0x1d68075b CGContextDelegateDrawImage + 46
9 CoreGraphics 0x1d6f227d CGContextDrawImageWithOptions + 420
10 CoreGraphics 0x1d6f2499 CGContextDrawImage + 52
11 QuartzCore 0x1f11b0bb CA::Render::(anonymous namespace)::create_image_by_rendering(CGImage*, CGColorSpace*, unsigned int, float) + 716
12 QuartzCore 0x1f11be43 CA::Render::(anonymous namespace)::create_image_from_rgb_image(CGImage*, CGColorSpace*, unsigned int, float) + 558
13 QuartzCore 0x1f11ab69 CA::Render::create_image(CGImage*, CGColorSpace*, unsigned int, float) + 456
14 QuartzCore 0x1f11c63b CA::Render::copy_image(CGImage*, CGColorSpace*, unsigned int, double, float) + 446
15 QuartzCore 0x1f1fdd1f -[CALayer(CALayerPrivate) _copyRenderLayer:layerFlags:commitFlags:] + 574
16 QuartzCore 0x1f1ff4c9 CA::Layer::copy_render_layer(CA::Transaction*, unsigned int, unsigned int*) + 34
17 QuartzCore 0x1f17e1a7 CA::Context::commit_layer(CA::Layer*, unsigned int, unsigned int, void*) + 90
18 QuartzCore 0x1f1f036b CA::Layer::commit_if_needed(CA::Transaction*, void ()(CA::Layer, unsigned int, unsigned int, void*), void*) + 324
19 QuartzCore 0x1f1410ad x_hash_table_foreach + 46
20 QuartzCore 0x1f19e06d CA::Transaction::foreach_root(void ()(CA::Layer, void*), void*) + 28
21 QuartzCore 0x1f17ecff CA::Context::commit_transaction(CA::Transaction*) + 1542
22 QuartzCore 0x1f19cfdb CA::Transaction::commit() + 578
23 QuartzCore 0x1f19db2f CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 162
24 CoreFoundation 0x1c32f803 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 20
25 CoreFoundation 0x1c32da55 __CFRunLoopDoObservers + 282
26 CoreFoundation 0x1c32e017 __CFRunLoopRun + 1358
27 CoreFoundation 0x1c2811af CFRunLoopRunSpecific + 470
28 CoreFoundation 0x1c280fd1 CFRunLoopRunInMode + 104
29 GraphicsServices 0x1da2bb41 GSEventRunModal + 80
30 UIKit 0x21609a53 UIApplicationMain + 150
31 Andyou 0x81a04 main (AppDelegate.swift:17)
32 libdyld.dylib 0x1ba6e4eb start + 2

apng's with transparent alpha, appear blown out

Loading in an apng appears to just assign alpha values of 1 or 0. Any alpha values above 0 appear to be clamped to 1. When I look at the apng's in Finder/Preview on a mac, the alpha works fine.

Won't build with xcode 10.0 beta 2

error: Cycle inside APNGKit; building could produce unreliable results.
Cycle details:
→ Target 'APNGKit' has link command with output '/Users/rob/Library/Developer/Xcode/DerivedData/ChillRemote-cdjhgicaxmoirdbnrfmvaaufhlfa/Build/Products/Debug-iphoneos/APNGKit/APNGKit.framework/APNGKit'

Showing All Messages
:-1: Cycle inside APNGKit; building could produce unreliable results.
Cycle details:
→ Target 'APNGKit' has link command with output '/Users/rob/Library/Developer/Xcode/DerivedData/ChillRemote-cdjhgicaxmoirdbnrfmvaaufhlfa/Build/Products/Debug-iphoneos/APNGKit/APNGKit.framework/APNGKit'

Carthage in Objective-C context

Hey,

I'm trying to use APNGKit with Carthage in Objective-C context. I can't use Swift because its an Unity project. Is this combination possible? I imported <APNGKit/APNGKit-Swift.h> but the header file does only expose the default init and initWithDecoder methods. I tried [[APNGImage alloc] contentsOfFile:@""] wich throws No visible @interface for 'APNGImage' declares the selector 'contentsOfFile:'

no functions visible in objective C

I can't see any init functions for either APNGImage or APNGImageView when trying to use in objective-c

I can see the Class name, but can't access any properties or functions
(using swift 4.2 in OBjective C project)

APNGImageView content mode

I don't see a "contentMode" for APNGImageView as UIImageView has. I know this is a UIViewSubclass, but how would I replicate this behavior so the image doesn't stretch?

Issue in compiling with xcode 8 - for legacy support - swift 2.3

Hi!

I am trying to use the library. I get error for below:
/APNGKit/Frame.swift:75:73: Nil is not compatible with expected argument type 'CGDataProviderReleaseDataCallback' (aka '@convention(c) (UnsafeMutablePointer<()>, UnsafePointer<()>, Int) -> ()')

Tried this for most versions of library - 0.1.0 to 0.1.4.

Please suggest way to deal with this. My project is in Swift 2.3, so need library compiled with 2.3 to be used.

Thanks!

returns image is nil

I have an apng image that has 200 frames and extension of pang image is .png
Whenever I do:

apngView = APNGImageView(image: image)

image is nil even though the image exists in assets

I am using Xcode9

Animation stops when scrolling

I have an APNGImageView in a collection view and whenever I start scrolling, the animation pauses. Once I stop scrolling, the animations speeds up and appears to catch up to where it would have been. How do I make it so the animation doesn't stop when scrolling?

Crash when Objective-C dealloc

Sometimes my app crashes when removing APNGImageView in Objective-C coded UIViewController .
In case of Swift, that's not happen.

I think this workaround is not enough for Objective-C.

// fix issue that `APNGImageView` may cause crash when deinit
layer.contents = nil

In Objective-C, sometimes deinit is not called when removing the APNGImageView from the parent view because of AutoreleasePool. So this workaround dose not affect, and crash it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.