distriqt / airnativeextensions

DEPRECATED: Original repository of the distriqt native extensions and is no longer maintained. Please see our site for the latest ANEs
https://airnativeextensions.com
2 stars 0 forks source link

NativeMaps ANE - iOS crash after more requestMapBitmapData callings #266

Closed buckleup closed 8 years ago

buckleup commented 9 years ago

when requesting more map bitmap screenshots in line when using NativeMaps on iOS the application crash on using resources (it takes some memory warnings from system before) ... it was tested on iOS 7 / 8 for example on iPad Mini taking 1536x1682 px screens it will crash after about 40 requests (on iPhone and smaller screenshot sizes it takes more time) ... it seems like extension is not deleting bitmap resources after taking screenshot ...

koriner commented 9 years ago

Thanks, I'll investigate this and see if I can reproduce the problem.

svonnidmeg commented 9 years ago

@koriner , I haven't any crash about this issue. The app I'm developing (Flash Pro CC 2014, Starling 1.5.1, Feathers 1.3.1, 60fps - noMap/30fps - yesMap) uses requestMapBitmapData callings (each time I want show popup over map) and works perfect (don't know if I've tested with 20, 30, 40 or 50 calls). Remember my old #237 issue (solved)

@buckleup ,

Marc

buckleup commented 9 years ago

@svonnidmeg @koriner

here is simple clean code with Timer to generate screenshots of map that will crash the application in 20 seconds on our Retina iPad mini iOS 8 ... i don't think there is something more we can do with optimizing this code as for memory usage (of course this is extreme example but nice for examine this issue :) ) ...

package projects.mvc {

import flash.display.MovieClip;

import flash.utils.Timer;

import flash.events.Event;
import flash.events.TimerEvent;

import com.distriqt.extension.nativemaps.NativeMaps;
import com.distriqt.extension.nativemaps.events.NativeMapEvent;
import com.distriqt.extension.nativemaps.events.NativeMapBitmapEvent;

public class MapCrash extends MovieClip {

    public static const DEV_KEY:String = "";    

    private var _timer:Timer;

    public function MapCrash() {

        NativeMaps.init(DEV_KEY);

        this.addEventListener(Event.ADDED_TO_STAGE, onStageAdded, false, 0, true);

        _timer = new Timer(500, 1);
        _timer.addEventListener(TimerEvent.TIMER, onThisTimer, false, 0, true);

    }

    private function onStageAdded(e:Event):void {

        MapCreate();

    }

    private function MapCreate():void {

        if (NativeMaps.isSupported) {

            NativeMaps.service.addEventListener(NativeMapEvent.MAP_CREATED, onMapCreated, false, 0, true);
            NativeMaps.service.addEventListener(NativeMapBitmapEvent.READY, onMapBitmapReady, false, 0, true);
            NativeMaps.service.createMap(this.stage.fullScreenWidth, this.stage.fullScreenHeight, 0, 0);

        }

    }

    private function onMapCreated(e:NativeMapEvent):void {

        _timer.reset();
        _timer.start();

    }

    private function MapBitmapCreate():void {

        NativeMaps.service.requestMapBitmapData();

    }

    private function onMapBitmapReady(e:NativeMapBitmapEvent):void {

        e.bitmapData.dispose();

        _timer.reset();
        _timer.start();

    }

    private function onThisTimer(e:TimerEvent):void {

        MapBitmapCreate();

    }

}

}