Inconsistent onNewPicture method
===

While playing a little with hiding WebView off the screen during the page load, I have decided to work it around with PictureListener, here are the code snippets:

>         onCreate:

    webView.addJavascriptInterface(new JavaScriptInterface(this), "test");
    webView.setPictureListener(new CustomPictureListener());


> ....... extends WebViewClient

>         onPageStarted:

    view.setVisibility(View.INVISIBLE);
    loadingProgress.show();

>         onPageFinished

    String doJS  = "javascript:window.test.countImages(document.getElementsByTagName('img').length);";
    view.loadUrl(doJS);

>  ........implements PictureListener

>          onNewPicture

			images++;

			if (loadingProgress.isShowing()
					&& ActivityName.this.amount == images
					&& ActivityName.this.amount > 0) {

				if (loadingProgress.isShowing()) {
					webView.startAnimation(animation);
					loadingProgress.dismiss();
					webView.setVisibility(View.VISIBLE);
				}

			}


> ...... class JavaScriptInterface

>         countImages()

			ActivityName.this.amount = Integer
					.parseInt(html);


And I am loading local page (from assets) (FB login page)

And the problem is that every time onNewPicture method intercepts different amount of pictures, so this code is not good, since it is not consistent
As an example from the runtime: countImages() method returns 4 pictures, but onNewPicture, however, runs 2-4 times, sometimes even 1 time. I have tried removing cache, but it does not help - result is the same.

Why onNewPicture method is so inconsistent?