flash player internals

23
White Master Replace with a graphic 5.5” Tall & 4.3” Wide ight 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 1 Flash Player Internals Alberto González Sr. Technical Consultant

Upload: alberto-gonzalez

Post on 15-Dec-2014

892 views

Category:

Technology


0 download

DESCRIPTION

Flash Player Internals

TRANSCRIPT

Page 1: Flash Player Internals

White Master

Replace witha graphic

5.5” Tall & 4.3” Wide

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 1

Flash Player Internals

Alberto GonzálezSr. Technical Consultant

Page 2: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 2

Bio

Director de Tecnología en Activ (Adobe Authorized Training Center)

+9 años de experiencia trabajando con la plataforma Flash, ActionScript y tecnologías de servidor.

Co-manager del grupo de usuarios, oficial de Adobe, enfocado a Rich Internet Applications ( RIActive – www.riactive.com )

Consultor de Adobe Mex enfocado en tecnologías de programación

Conferencista en diversos eventos internacionales como Software Guru, Adobe en vivo, Adobe Hispano, presentación de productos: CS3 – CS4, Flex y AIR, Flash Builder, Flash Catalyst,…

Page 3: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 3

Flash Player

Mismo código base para todos los dispositivos ( 80% es “core” )

Actualizamos/mejoramos el “core” y se aplica de forma automática

Otra parte del código es específico de la plataforma Mobile* (Palm, Symbian, …)

Desktop (Mac, Window, Linux)

Mismo código, misma liberación, misma estrategia para dispositivos móviles y escritorio.

Page 4: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 4

Flash Player en laptops, desktop, dispositivos

Consistente

Multi-plataforma

Optimizado

Existen diferencias mayores

Memoria y CPU (Quad Core, Palm, Core 2 Duo, …)

Resolución (1600x1280, 320x260, …)

Mouse, teclado, touchscreen

Page 5: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 5

Flash Player

Hay que ser cuidadoso// Fallará el flash player en un móvil con 100MB de RAM

for( int i=0; i<10; ++i ) {

data[i] = new BitmapData( 1600, 1600 );

}

Page 6: Flash Player Internals

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 6

Infraestructura

Flash Player

Page 7: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 7

Modelo de ejecución (Flash) : Basado en “frames”

( Browser )

Acciones SWF

ActionScript

Rendering

Page 8: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 8

Modelo de ejecución

// Este código no hace lo que esperaríamos

// El “Render” no es invocado

for( var i:int; i < 100; i++){

clip.x++;

}

Page 9: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 9

Modelo de ejecución

// Siempre hay una excepción.

start = getTimer();

bitmapData.draw(…);

end = getTimer();

Page 10: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 10

Modelo de ejecución (Flash) : Basado en “frames”

[Evento] enterFrame

Constructores

[Evento] frameConstructed

Scripts del frame

[Evento] exitFrame

Rendereo del Frame

Page 11: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 11

Modelo de ejecución (Flex) : Basado en eventos

Evento(Browser)

(null)

ActionScript

Rendering

Page 12: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 12

Prioridades de performance en Flash Player

Sonido streaming

Video

ActionScript + Rendering

Page 13: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 13

Versiones

Versión del Flash Player vs versión del SWF

La “versión” es virtual

Aplica a: Funcionalidades

APIs

Bug fixes

Page 14: Flash Player Internals

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 14

ActionScript

Page 15: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 15

ActionScript VMs

ActionScript 2 se ejecuta en AVM1 Interpretado

ActionScript 3 se ejecuta en AVM2 “Tamarin VM” JIT – Convierte el ABC (ActionScript Byte Code) a “código máquina”

ejecutable

Nanojit, nuevo!!!

Nanojit tiene soporte de la comunidad

Nanojit soporta múltiples procesadores

Nuevo en Flash Player 10.1 Clase “String” mejorada de manera interna

GC ha sido mejorado

Mobile principalmente

Pocas mejoras en multi-plaforma

Page 16: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 16

Garbage Collector (Recolector de basura)

Tipos primitivos, referencias y objetos

Recolección de basura no es manejo de memoria

Si el manejo de memoria realmente importa en tu aplicación Comienza desde el principio

Utiliza dos algoritmos: Conteo de referencias

Mark and sweep

Código de ayuda flash.system.System.gc();

Flash Player >= 9.0.115

Page 17: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 17

Alchemy

Podemos “inyectar” código C / C++ directo a los SWFs

Soporte limitado pero útil

Ideal para utilizar librerías de C / C++ en aplicaciones web (Flash Player) y escritorio (Adobe AIR)

Manipulación de datos

Decodificación de audio/video

“Parseo” de XML u otros formatos

Funciones criptográficas

Simulaciones físicas

No es una alternativa para evadir la seguridad en la plataforma

Proyecto Alchemy ( http://labs.adobe.com/technologies/alchemy )

Page 18: Flash Player Internals

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 18

Rendering…

Page 19: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 19

GPU vs Software Rendering

“Rendereo” por software:

“Rendereo” por GPU

+

Page 20: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 20

Video y optimización de bitmaps

Video decodificado en GPU

H.264

Soportado en todos los “wmodes”

JPEG descompresión bajo demanda

Instancias por superficie

La memoria sin utilizar es liberada

Page 21: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 21

Vectores en GPU

Dispositivos Móviles

Reemplaza el render por software con render GPU

Teoría: Mover lo gráfico de la computación del CPU al GPU

Page 22: Flash Player Internals

®

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 22

Performance

ActionScript Utilizar ActionScript 3

Tener cuidado con los intervalos y los altos “frame rates”

DisplayList (móviles) Mantenerla lo más pequeña posible

Video Resoluciones, formatos y “frame rate” apropiados

Page 23: Flash Player Internals

White Master

Replace witha graphic

5.5” Tall & 4.3” Wide

Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 23

Q & A

Alberto González

E-mail:[email protected]

Twitter:@albertx

Blog:http://x-geom.net/blog