Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Reuse of instance not possible #42

Open
ThaDafinser opened this issue Jun 3, 2016 · 5 comments
Open

Reuse of instance not possible #42

ThaDafinser opened this issue Jun 3, 2016 · 5 comments

Comments

@ThaDafinser
Copy link
Contributor

If you reuse the same HD4 instance, sometimes the results are from previous detections.

$parser->deviceDetect($headers);
$resultRaw = $parser->getReply();

$parser->deviceDetect($otherHeaders);
$resultRaw = $parser->getReply();
//...the result can be from previous detection

I tried already to set

$parser->reply = [];
$parser->rawreply= [];
$parser->detectRequest = [];

But that seems not enough.

@elricho
Copy link
Member

elricho commented Jun 7, 2016

We're investigating this now.

@elricho
Copy link
Member

elricho commented Jun 7, 2016

@ThaDafinser : Can you provide the http headers you're using ? Im struggling to reproduce this issue. Thanks.

@ThaDafinser
Copy link
Contributor Author

I run all 33.000 useragents from http://thadafinser.github.io/UserAgentParserComparison/
Then i had nearly 100% detection results, with some results populated wrong...

Need to check how i can reproduce it with a testcase

@ThaDafinser
Copy link
Contributor Author

I'm creating now a new instance...could not verify the issue exactly, so i use this as a workaround

$parser = new Parser\HD4($parser->config);

class HDStore implements \Iterator {
	/**
	 * Get the Singleton
	 *
	 * @param void
	 * @return Object $_instance
	 **/
	public static function getInstance() {
	    return self::$_instance = new self();
    }
}

@elricho
Copy link
Member

elricho commented Dec 21, 2016

Its odd - Im not sure where to start. In your 3 Jun example can you provide the headers ?
In my minimal test case I get the expected results (see below). I thought perhaps empty fields in results might get data from the previous detection, but the app detection from the first run (facebook), comes out empty in the second run (no app) which is what i expect .....

// Create a new detection object
$hd = new HandsetDetection\HD4($configFile);
//$hd->deviceFetchArchive();

$result = $hd->deviceDetect(array('user-agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13F69 [FBAN/FBIOS;FBAV/60.0.0.37.141;FBBV/34183777;FBRV/0;FBDV/iPhone7,2;FBMD/iPhone;FBSN/iPhone OS;FBSV/9.3.2;FBSS/2;FBCR/AT&T;FBID/phone;FBLC/en_US;FBOP/5]'));
echo json_encode($hd->getReply())."\n";

$result = $hd->deviceDetect(array('user-agent' => 'Mozilla/5.0 (Linux; U; Android 2.1-update1; cs-cz; SonyEricssonX10i Build/2.1.B.0.1) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17'));
echo json_encode($hd->getReply())."\n";

{"status":0,"message":"OK","hd_specs":{"general_vendor":"Apple","general_model":"iPhone 6","general_platform":"iOS","general_platform_version":"9.3.2","general_platform_version_max":"","general_browser":"","general_browser_version":"","general_image":"appleiphone6-1415321342-0.jpg","general_aliases":[],"general_eusar":"0.98 Head","general_battery":["Li-Po 1810 mAh"],"general_type":"Mobile","general_cpu":["Dual Core","1.4GHz","Cyclone ARMv8","PowerVR GX6450"],"general_virtual":0,"design_formfactor":"Bar","design_dimensions":"138.1 x 67 x 6.9","design_weight":"129","design_antenna":"Internal","design_keyboard":"Screen","design_softkeys":"2","design_sidekeys":["Volume","Power"],"display_type":"IPS LCD","display_color":"Yes","display_colors":"16M","display_size":"4.7\"","display_x":"750","display_y":"1334","display_ppi":326,"display_pixel_ratio":"2.0","display_css_screen_sizes":["375x667","320x568"],"display_other":["Capacitive Touchscreen","Multitouch","Oleophobic Coating","Shatter Proof Glass"],"memory_internal":["16GB ROM","64GB ROM","128GB ROM","1GB RAM"],"memory_slot":["None"],"network":["GSM850","GSM900","GSM1800","GSM1900","EDGE850","EDGE900","EDGE1800","EDGE1900","HSDPA850","HSDPA900","HSDPA1700","HSDPA1900","HSDPA2100","UMTS850","UMTS900","UMTS1700","UMTS1900","UMTS2100","HSPA850","HSPA900","HSPA1700","HSPA1900","HSPA2100","CDMA800","CDMA1900","CDMA2100","LTE700","LTE800","LTE850","LTE900","LTE1800","LTE2100","LTE2300","LTE2600","WiFi","802.11a","802.11b","802.11g","802.11n","802.11ac","Bluetooth 4.0","NFC","HSDPA 42Mbps","HSUPA 5.76Mbps","EV-DO Rev. A"],"media_camera":["8MP","3264x2448"],"media_secondcamera":["1.2MP","1920x1080"],"media_videocapture":["Yes","1080p @60fps","720p@240fps"],"media_videoplayback":["H.264","H.265","MPEG-4","3GP","MP4","FLV","AVI","MOV","H.263","M4V"],"media_audio":["AAC","HE-AAC","MP3","VBR","MP4","AIFF","AAC-LC","PCM","WAV","MIDI","OGG","eAAC+"],"media_other":["AutoFocus","F\/2.2 Aperture","Backside illumination Sensor","Auto Image Stabilization","HDR","Face Detection","Exposure Compensation","Panorama","Burst Mode","Touch Focus","Geo-Tagging","Timer Mode","3x Digital Zoom","HD Video Recording","Dual LED Flash","1\/3'' Sensor Size","Simultaneous HD video and image Recording","Smile Detection","Video Calling","Date Tagging","Sapphire Crystal Lens Cover","IR Filter"],"features":["Retina HD Display","LED Backlight","Fingerprint Identity Sensor","GLONASS","Digital Compass","Barometer Sensor","Three-axis Gyroscope Sensor","Accelerometer","Proximity Sensor","Ambient Light Sensor","Vibration","Loudspeaker","Active noise cancellation with dedicated mic","Siri natural language commands and dictation","Flight Mode","Orientation Support","Speakerphone","Voice Recognition","Qi Case"],"connectors":["3.5mm Audio","USB 2.0","TV Out","MicroUSB 2.0"],"benchmark_min":1900,"benchmark_max":2300,"general_app":"Facebook","general_app_version":"60.0","general_app_category":"social","general_language":""}}

{"status":0,"message":"OK","hd_specs":{"general_vendor":"SonyEricsson","general_model":"X10I","general_platform":"Android","general_platform_version":"2.1.1","general_browser":"Android Webkit","general_browser_version":"4.0","general_image":"sonyericssonx10i-1370414043-6.jpg","general_aliases":["SonyEricsson Xperia X10","SonyEricsson X10"],"general_eusar":"","general_battery":["Li-Po 1500 mAh","BST-41"],"general_type":"Mobile","general_cpu":["1.0GHz"],"design_formfactor":"Bar","design_dimensions":"119 x 63 x 13","design_weight":"135","design_antenna":"Internal","design_keyboard":"Screen","design_softkeys":"","design_sidekeys":["Volume","Camera"],"display_type":"TFT","display_color":"Yes","display_colors":"65K","display_size":"4\"","display_x":"480","display_y":"854","display_other":["Capacitive","Touch","Multitouch"],"memory_internal":["1GB","384MB RAM"],"memory_slot":["microSD","microSDHC","32GB","8GB"],"network":["GSM850","GSM900","GSM1800","GSM1900","UMTS900","UMTS1700","UMTS2100","HSDPA900","HSDPA1700","HSDPA2100","Bluetooth 2.1","802.11b","802.11g","GPRS Class 10","EDGE Class 10"],"media_camera":["8MP","3264x2448"],"media_secondcamera":[],"media_videocapture":["WVGA@30fps"],"media_videoplayback":["MPEG4"],"media_audio":["MP3","AAC","AAC+","WMA","WAV"],"media_other":["Auto focus","Image stabilizer","Video stabilizer","Face detection","Smile detection","Digital zoom","Geo-tagging","Touch focus","LED Flash"],"features":["Unlimited entries","Caller groups","Multiple numbers per contact","Search by both first and last name","Picture ID","Ring ID","Calendar","Alarm","Document viewer","Calculator","World clock","Stopwatch","Notes","Computer sync","OTA sync","Music ringtones (MP3)","Polyphonic ringtones","Vibration","Flight mode","Silent mode","Speakerphone","Voice recording","Accelerometer","Compass","Timescape\/Mediascape UI","SMS","Threaded viewer","MMS","Email","Push email","IM","Google Search","Maps","Gmail","YouTube","Google Talk","Facebook and Twitter integration","Voice memo","Games"],"connectors":["USB 2.0","MicroUSB","3.5mm Audio"],"general_platform_version_max":"","general_app":"","general_app_version":"","general_language":"","display_ppi":245,"display_pixel_ratio":"1.50","benchmark_min":0,"benchmark_max":0,"general_app_category":"","general_virtual":0,"display_css_screen_sizes":["480x854"]}}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants